Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
omega1983
Starting Member
40 Posts |
Posted - 2009-10-02 : 11:13:13
|
| Is there such a thing as multiple having clause in sql 2005Here is my codeselect count(id),batch, class, datefrom Giftsgroup by batch,class,datehaving count(batch)>1my desired output is batch class2322 m2322 bIn 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? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-02 : 11:18:33
|
do you mean this?SELECT t.*FROM Gifts tJOIN (select batchfrom Giftsgroup by batchhaving count(class)>1)t1ON t1.batch=t.batch |
 |
|
|
mivey4
Yak Posting Veteran
66 Posts |
Posted - 2009-10-02 : 11:18:39
|
| Yes. The syntax would be:select count(id),batch, class, datefrom Giftsgroup by batch,class,datehaving (count(batch)>1and count(class)>1) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-02 : 11:18:57
|
you can use AND operatorhaving count(batch) > 1AND count(class) > 1 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-02 : 11:19:56
|
Slow again. And this time double  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|