开发者

how to select top 5 max values in mytable

Please help me with Query in Mysql.. i am Having table contains lot of rows .now i want retrive the 5 rows from t开发者_JAVA技巧hat table.

my requirement is top maximum 5 values in that table "column name is amount" i want select from that table.outof N records i need top max 5 records from table

Thanking you,


Just order the rows by (descending) amount and take the top 5:

SELECT amount FROM mytable ORDER BY amount DESC LIMIT 5

Note that this will result in a full table scan unless you have an index on the amount column. This could affect performance if the number of rows in the table is very large (i.e. many thousands).


SELECT * FROM table ORDER BY amount DESC LIMIT 5;

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜