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
 Transact-SQL (2000)
 Select with more than one occurance

Author  Topic 

Twolak
Starting Member

2 Posts

Posted - 2005-05-05 : 12:53:50
I have a table parts with few columns among which color, style, manufacturer, version, form a key.
What I want to do is to select style that occours in the table most frequently
Select style from parts where max(occurance of style)

Having problems coming up with the right sql for that. Any ideas?
Thanks

mfemenel
Professor Frink

1421 Posts

Posted - 2005-05-05 : 14:00:33
select style,count(style) from table group by style order by count(style) asc

Mike
"oh, that monkey is going to pay"
Go to Top of Page

Twolak
Starting Member

2 Posts

Posted - 2005-05-05 : 14:59:17
Thanks,
That will do. Cannot believe how simple it is and that I didn't think of it :).
Cheers

Tomasz
Go to Top of Page
   

- Advertisement -