Query to find Max Salary along with Employee name

Write a SQL query to display employee who is earning maximum salary.

SELECT first_name,salary
FROM employees
WHERE salary=(SELECT MAX(salary) FROM employees);

Another way: Using row num


SELECT *FROM
  (SELECT row_number() over (order by salary DESC) AS r,first_name,salary
   FROM employees
  )
WHERE r = 1;

Leave a Reply

Your email address will not be published. Required fields are marked *