SQL查询以获取表中的最大值 [英] SQL query to get highest values in a table
本文介绍了SQL查询以获取表中的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张包含以下信息的表格:
I have a table with the following information:
ID Name Value
=== ===== =======
1 apple 5
2 green 10
3 orange 1
4 blue 0
5 fish 3
6 lettuce 2
7 cabbage 4
8 computer 1
9 car 0
10 sport 9
11 racing 15
我希望只能在此表中提取 3 个最高值记录.因此,例如,我想按该顺序提取以下内容.
I want to be able to only pull 3 highest value records in this table. So for example i would want to pull the following in that order.
11 racing 15
2 green 10
10 sport 9
我知道我可以使用 ORDER BY 按值对它们进行排序,因此它首先给我最高的.但是我如何查询以只获取这些记录?
I know i can use ORDER BY to order them by value so it gives me the highest first. But how would i query to only get those records?
推荐答案
你可以这样做
select * from your_table order by Value desc limit 3
这篇关于SQL查询以获取表中的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文