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,454
- 8
- 66
- 101
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
- 47,486
- 13
- 97
- 124