+ 6

Which query will you use to display details of employees having second maximum salary ?😇😇

Brain Teaser 😋

22nd Jan 2017, 6:35 PM
Jenny Lance
Jenny Lance - avatar
4 Réponses
+ 14
I got it ! SELECT * FROM EMP WHERE SAL = (SELECT MAX(SAL) FROM EMP WHERE SAL< ( SELECT MAX(SAL) FROM EMP); 😋😋
23rd Jan 2017, 5:22 AM
Jenny Lance
Jenny Lance - avatar
+ 2
select *from emp order by sal desc limit 1,1;
1st Sep 2017, 5:45 PM
Sukumar
Sukumar - avatar
+ 2
select * from emp where sal < (select sal from emp order by sal desc limit 1,1) ; to select everyone whose salary is less than the second highest salary
1st Sep 2017, 5:51 PM
Sukumar
Sukumar - avatar
+ 1
select top 1 * from emp where ID in (select top 2 ID from emp order by sal desc) order by sal I think that would do it too..
11th Feb 2017, 12:10 PM
Luke T
Luke T - avatar