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 |
neolegionar
Starting Member
3 Posts |
Posted - 2008-01-13 : 14:02:48
|
Hi thereI have a table called orders with a column called client_idfor eg if i have in client_id these values.. . 1,2,3,4,5,1,1,2,3,1,1,1,2 i want to select 1 i mean the one with maximum frequency !thx.. |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2008-01-13 : 17:20:23
|
Select max(Count(Client_ID)FROM ordersorSelect Top 1 ClientID,Count(*)FROM OrdersGROUP BY CLientIDORder by Count(*) DESC Poor planning on your part does not constitute an emergency on my part. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-13 : 21:21:34
|
quote: Originally posted by dataguru1971 Select max(Count(Client_ID)FROM orders
You can't perform an aggregate function on another aggregate function. KH[spoiler]Time is always against us[/spoiler] |
 |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2008-01-13 : 21:53:02
|
I know...can't anyone here take a joke? LOLI meant to show it as a derived/sub query..but got a little lazy...many apologies...:o) Poor planning on your part does not constitute an emergency on my part. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-13 : 21:56:20
|
quote: Originally posted by dataguru1971 I know...can't anyone here take a joke? LOLI meant to show it as a derived/sub query..but got a little lazy...many apologies...:o) Poor planning on your part does not constitute an emergency on my part.
Oh really   KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|