Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping and totalling in SQL query

Status
Not open for further replies.

DebbieDavis

Programmer
Jun 7, 2002
146
US
I've looked for a similar answer to my problem but can't seem to find anything that works. I have the following query:
Code:
SELECT *
FROM dbo.customers LEFT OUTER JOIN
    dbo.gifts ON 
    dbo.customers.contactid = dbo.gifts.giftcustomerid
WHERE (dbo.customers.expanded IS NOT NULL) AND 
    (dbo.customers.unsubscribe IS NULL) AND 
    (dbo.customers.dist IS NULL)

What I need to do is group by a field call affid, then count by the number of records per affid. But when I group, etc. there are too many fields to group on so I don't get a proper count... I don't know how to do a nested query. I hope this makes sense. Thanks for any thoughts you have.
 
It would be better if you show your table and the result you are looking for...

then it would be easy for someone to help you out..

Thanks..

-VJ
 
For SQL help, you might find more assistance in forum183.

------------------------------------------------------------------------------------------------------------------------
"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."
--Dou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top