Below are different ways to find the maximum salary from Employees table using oracle SQL.
SELECT MAX (salary) FROM employees;
SELECT salary FROM (
SELECT salary, row_number () OVER (ORDER BY salary DESC ) r FROM employees
)WHERE r = 1;
SELECT salary FROM (
SELECT salary, RANK () OVER (ORDER BY salary DESC ) r FROM employees
)WHERE r = 1;
SELECT * FROM (SELECT * FROM employees ORDER BY salary DESC ) WHERE ROWNUM =1;
SELECT * FROM employees e1 WHERE 1=(SELECT COUNT (* ) FROM employees e2 WHERE e2.salary>=e1.salary);
SELECT * FROM employees WHERE salary > ALL (
SELECT salary - 1 FROM employees);
SELECT * FROM employees ORDER BY salary DESC FETCH FIRST 1 ROW ONLY ; /* This query will work in oracle 12C and above */
Avanita on Nov 09, 2020 at 12:11 am
This article is contributed by Avanita .
If you like dEexams.com and would like to contribute,
you can write your article here or mail your article to admin@deexams.com .
See your article appearing on the dEexams.com main page and help others to learn.
Post Comment
Comments( 0)