﻿ PostgreSQL Basic SELECT Statement: Get the maximum and minimum salary paid to the employees - w3resource

# PostgreSQL Basic SELECT Statement: Get the maximum and minimum salary paid to the employees

7. Write a query to get the maximum and minimum salary paid to the employees.

Sample Solution:

Code:

``````-- Selecting the maximum and minimum salary from the employees table
SELECT MAX(salary), MIN(salary)
-- Selecting data from the employees table
FROM employees;
``````

Explanation:

• This SQL code selects the maximum and minimum salary values from the "employees" table.
• The MAX() function returns the highest salary value in the "salary" column.
• The MIN() function returns the lowest salary value in the "salary" column.
• The result set will contain two columns: the maximum salary and the minimum salary.

Sample table: employees

Output:

```pg_exercises=# SELECT MAX(salary), MIN(salary)
pg_exercises-# FROM employees;
max    |   min
----------+---------
24000.00 | 2100.00
(1 row)
(1 row)
```

## Practice Online

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

﻿