tags:

views:

24

answers:

1

my table look like this..

id name count
-- ---- -----
1 Mike 0
2 Duke 2
3 Smith 1
4 Dave 6
5 Rich 3
6 Rozie 8
7 Romeo 0
8 Khan 1
----------------------

I want to select rows with max(count) limit 5 (TOP 5 Names with maximum count)

that would look sumthing like...

id name count
-- ---- -----
6 Rozie 8
4 Dave 6
5 Rich 3
2 Duke 2
3 Smith 1

please help,,

thanks

+1  A: 

Here is how:

MySQL:

SELECT * FROM tableName ORDER BY count DESC LIMIT 5

MS SQL:

SELECT TOP 5 * FROM tableName ORDER BY count DESC
Sarfraz
y didnt i think of that :P wat a dumb..
Wasim