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 |
|
txk2601
Starting Member
19 Posts |
Posted - 2009-03-07 : 10:52:41
|
| Hi all.I have got problem with Max/Min and Count functions by following:SELECT BookTypeID, MIN(Count(BookID)) From tblBookInfo GROUP By BookTypeIDI receive a message "Cannot perform an aggregate function on an expression containing an aggregate or a subquery." Please help me. Thanks a lot |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2009-03-07 : 12:40:49
|
| use sub query to count first |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-07 : 13:24:34
|
| [code]SELECT MIN(BookCount)FROM(SELECT BookTypeID, Count(BookID) AS BookCount From tblBookInfo GROUP By BookTypeID)t[/code] |
 |
|
|
txk2601
Starting Member
19 Posts |
Posted - 2009-03-09 : 21:49:05
|
| Thanks visakh16 and Lionofdezert very much! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-10 : 03:08:09
|
| welcome |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-10 : 04:51:54
|
| orSELECT top 1 BookTypeID, Count(BookID) From tblBookInfo GROUP By BookTypeIDorder by Count(BookID) ascMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|