How to find second highest salary from a table? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to find second highest salary from a table?

2nd Sep 2016, 2:22 PM
Kirtiranjan Sahoo
Kirtiranjan Sahoo - avatar
2 Answers
+ 1
select all records, order by salary DESC and limit 2. then you can get the second record of the table using the programming language that you are using
2nd Sep 2016, 4:51 PM
Luis Arce
Luis Arce - avatar
0
select *from table t1 where 1=(select count(*) from table t2 where t2.sal>t1.max(sal))
3rd Sep 2016, 7:45 AM
Pujari Sruthi
Pujari Sruthi - avatar