How to find 2nd and 3rd largest amount from a table
+7
A:
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.
ThiefMaster
2010-05-19 12:39:02
A:
SQL Server 2000+
SELECT TOP 2
*
FROM
(
SELECT TOP 3 * FROM table ORDER BY Something DESC
) T
ORDER BY Something
gbn
2010-05-19 12:57:14
A:
If you are using SQL Server 2005+ you can use the ROW_NUMBER construct.
Brian Gideon
2010-05-19 13:59:09