开发者

Select max value rows from table column

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


Here is how:

MySQL:

SELECT * FROM tableName ORDER BY count DESC LIMIT 5

MS SQL:

SELECT TOP 5 * FROM tableName ORDER BY count DESC
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜