Reputation: 1863
I have a table like this:
id | name | class | marks
1 | abc | 1 | 90
2 | cdf | 1 | 100
3 | xyz | 1 | 70
I want to get 2nd highest marks record. How can I get it with with one query. Simple and short?
Upvotes: 2
Views: 314
Reputation: 64409
Use LIMIT
and ORDER
SELECT * FROM table
ORDER BY marks DESC LIMIT 1,1
ORDER BY marks DESC means: descending ordering, so highest on top. LIMIT 1,1 means offset = 1 and only select 1 row.
Upvotes: 4