I would like to know if I have a certain table, let's say table X which contains salary and names, how would I display the maximum salary along with corresponding names? Thank you.
Asked
Active
Viewed 25 times
2 Answers
1
select salary, name
from X
where salary = (select MAX(salary) from X)
Stijn Geukens
- 15,149
- 7
- 65
- 100
0
Let's see this using EMP table example :
SQL> WITH DATA AS(
2 SELECT MAX(sal) max_sal FROM emp)
3 SELECT ename, sal
4 FROM emp
5 WHERE sal = (SELECT max_sal FROM DATA)
6 /
ENAME SAL
---------- ----------
KING 5000
SQL>
Lalit Kumar B
- 45,678
- 12
- 90
- 118