+ 1
How can I check second highest salary in emp_sal
2 Respuestas
+ 5
Assuming the table "emp_sal" and the field "salary"; you can try the following query:
[MySQL]
SELECT salary FROM emp_sal WHERE salary < MAX(salary) ORDER BY salary DESC LIMIT 1;
[Microsoft SQL Server]
SELECT TOP 1 salary FROM emp_sal WHERE salary < MAX(salary) ORDER BY salary DESC;
[Oracle]
SELECT salary FROM emp_sal WHERE salary < MAX(salary) AND ROWNUM < 2 ORDER BY salary DESC;
Hth, cmiiw
+ 3
select max(emp_sal) from employee where emp_sal<(select max(emp_sal) from employee);
To go further down your list, you need to repeat the where condition continuously.