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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 The one with maximum frequency

Author  Topic 

neolegionar
Starting Member

3 Posts

Posted - 2008-01-13 : 14:02:48
Hi there

I have a table called orders with a column called client_id
for 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 orders


or

Select Top 1 ClientID,Count(*)
FROM Orders
GROUP BY CLientID
ORder by Count(*) DESC




Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

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]

Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-01-13 : 21:53:02
I know...can't anyone here take a joke? LOL

I 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.

Go to Top of Page

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? LOL

I 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]

Go to Top of Page
   

- Advertisement -