Friday, 3 May 2013

nth highest data

SELECT * FROM table_name order by column_name asc limit x, y;


y->how many record do you want to fetch
x->in records which one do you want to select as for
second x = 1
for third x = 2

i have 15 record i want third highest salary then
select * from table_name order by salary desc limit 2,1

No comments:

Post a Comment