Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Select highest salary in MySQL?
For this, you can use MAX(). The syntax is as follows −
select MAX(yourColumnName) AS anyAliasName from yourTableName;
Let us create a table −
mysql> create table demo44 −> ( −> employee_id int not null auto_increment primary key, −> employee_name varchar(20), −> employee_salary int −> ) −> ; Query OK, 0 rows affected (1.27 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo44(employee_name,employee_salary) values('John',3000);
Query OK, 1 row affected (0.13 sec)
mysql> insert into demo44(employee_name,employee_salary) values('David',4500);
Query OK, 1 row affected (0.12 sec)
mysql> insert into demo44(employee_name,employee_salary) values('Bob',3500);
Query OK, 1 row affected (0.12 sec)
mysql> insert into demo44(employee_name,employee_salary) values('Carol',5500);
Query OK, 1 row affected (0.15 sec)
mysql> insert into demo44(employee_name,employee_salary) values('Mike',4900);
Query OK, 1 row affected (0.13 sec)
Display records from the table using select statement −
mysql> select *from demo44;
This will produce the following output −
+-------------+---------------+-----------------+ | employee_id | employee_name | employee_salary | +-------------+---------------+-----------------+ | 1 | John | 3000 | | 2 | David | 4500 | | 3 | Bob | 3500 | | 4 | Carol | 5500 | | 5 | Mike | 4900 | +-------------+---------------+-----------------+ 5 rows in set (0.00 sec)
Following is the query to select highest salary −
mysql> select MAX(employee_salary) AS Highest_Salary from demo44;
This will produce the following output −
+----------------+ | Highest_Salary | +----------------+ | 5500 | +----------------+ 1 row in set (0.00 sec)
Advertisements
