Try it here
Subscribe
Get Max Salary Oracle SQL

Different ways to get maximum salary using Oracle SQL

different_way_to_get_maximum_salary_using_oracle_sql

Below are different ways to find the maximum salary from Employees table using oracle SQL.


  1. SELECT MAX(salary) FROM employees;

  2. SELECT salary FROM ( SELECT salary, row_number() OVER(ORDER BY salary DESC) r FROM employees )WHERE r = 1;

  3. SELECT salary FROM ( SELECT salary, RANK() OVER(ORDER BY salary DESC) r FROM employees )WHERE r = 1;

  4. SELECT * FROM (SELECT * FROM employees ORDER BY salary DESC) WHERE ROWNUM=1;

  5. SELECT * FROM employees e1 WHERE 1=(SELECT COUNT(*) FROM employees e2 WHERE e2.salary>=e1.salary);

  6. SELECT * FROM employees WHERE salary > ALL( SELECT salary - 1 FROM employees);

  7. SELECT * FROM employees ORDER BY salary DESC FETCH FIRST 1 ROW ONLY; /* This query will work in oracle 12C and above */

Writer profile pic

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)

×

Forgot Password

Please enter your email address below and we will send you information to change your password.