Query to get 3rd largest amount and 2nd largest amount from table
How to find 2nd and 3rd largest amou开发者_开发知识库nt from a table
SELECT ... FROM ... ORDER BY column DESC LIMIT 2 OFFSET 1;
Depending on your SQL dialect there's a different way of specifying LIMIT and OFFSET.
SQL Server 2000+
SELECT TOP 2
*
FROM
(
SELECT TOP 3 * FROM table ORDER BY Something DESC
) T
ORDER BY Something
If you are using SQL Server 2005+ you can use the ROW_NUMBER construct.
精彩评论