Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何从mysql中的表中获取第n个最大值请给我一个简单的查询
SELECT expectedValue FROM fooTable ORDER BY expectedValue LIMIT n-1,1
其中 n 是您的nth价值(n-1零索引)
nth
n-1
查看此 sql fiddle 以检索第 5 个更高的值:示例
SELECT DISTINCT(your_value) FROM table ORDER BY your_column DESC LIMIT n-1,1