Find Highest Salary
We can use the keyword MAX to find the highest value of a column from a table.
- MAX, which returns the maximum value of a column
Let's assume a table with the below table definition and data, where we need to find the highest salary.
id name salary
===========================
1 Arun 20000
2 Kiran 15000
3 James 35000
4 Sammy 50000
5 Martin 25000
SQL Query Using MAX
SELECT MAX(salary) FROM employees;
This query returns the maximum value of the salary column from an employee table, which is the highest salary.
SQL Query Using MAX and WHERE
SELECT MAX(salary) FROM employees WHERE id IN (1,3,5);
This query returns the highest salary among the employees included based on the WHERE condition.
In this example, the WHERE condition includes the employees with id as 1, 3, and 5.
Overall
We now know the SQL Query to find the highest value from a specific table column.