August 21, 2010
SQL All Keyword
All Keyword in SQL
Given the following database table: employee(emp_name, emp_salary) write an SQL statement to print the employee name with the highest salary
Solution
Using the max aggregate function will give us the maximum salary but it does not give us the name of the employee who has the maximum salary. The solution is to use the (ALL) keyword
Code
Here is the SQL statement
1 2 3 4 |
Select emp_name, emp_salary from employee where salary >= ALL (select unique salary from employee) |