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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple having Clause in SQL

Status
Not open for further replies.

vcujackson

Technical User
Apr 7, 2009
18
US
Is there such a thing as multiple having clause in sql 2005
Here is my code
select count(id),batch, class, date
from Gifts
group by batch,class,date
having count(batch)>1

my desired output is
batch class
2322 m
2322 b

In other word I want the gift batch to show only if there is more than one class. is there such a thing as
having count(batch)>1 and having count(class)>1?
 
try:

Code:
select   count(id),batch, class, date
from     Gifts
group by batch,class,date
having   Count(batch)>1
         And Count(class) > 1

I suspect that this is not what you want. Since you are grouping by batch, class, and date.... count(batch) will always be the same as count(class) unless you have nulls in your data.

If you post some sample data and expected results, it will be easier for us to give you better advice.


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top