Results 1 to 2 of 2

Thread: sql count by company

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Norwich, UK
    Posts
    405

    Unhappy sql count by company

    i want to return a count of the number of lproductid's for each company, so far i have this query

    select count(lproductid), companyname, customeragreementsent, customeragreementback
    from tblcompanies
    inner join tblCustomerAgreements as ca on tblcompanies.companyid = ca.companyid
    inner join tblallsubscribercodes as tas on ca.companyid = tas.companyid
    inner join ilabelserver.dbo.subscriber as isub on tas.subscribercode
    = isub.smanucode
    inner join ilabelserver.dbo.product as iprod on isub.lsubscriberid =
    iprod.lsubscriberid
    where customeragreementsent is not null and customeragreementback is null
    group by lproductid, companyname,customeragreementsent, customeragreementback

    but this does not pull back the correct results.
    can anyone help?

  2. #2
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313
    Trim your GROUP BY clause:

    from
    Code:
    group by lproductid, companyname,customeragreementsent, customeragreementback
    to
    Code:
    group by companyname

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width