w3resource

PostgreSQL Aggregate Functions and Group By: Find the minimum salary paid to the employee


3. Write a query to get the minimum salary from employees table.

Sample Solution:

Code:

-- Retrieve the minimum salary among all employees
SELECT MIN(salary) 
FROM employees;

Explanation:

  • This SQL query is designed to retrieve the minimum (lowest) salary among all employees stored in the database.
  • The MIN() function is an aggregate function in SQL that calculates the minimum value in a column.
  • salary is presumably a column in the employees table that holds the salary information for each employee.
  • The query calculates the minimum value in the salary column for all rows in the employees table.
  • The result will be a single value representing the lowest salary among all employees.

Sample table: employees


Output:

pg_exercises=# SELECT MIN(salary)
pg_exercises-# FROM employees;
   min
---------
 2100.00
(1 row)

Relational Algebra Expression:

Relational Algebra Expression: Find the minimum salary paid to the   employee.

Relational Algebra Tree:

Relational Algebra Tree: Find the minimum salary paid to the   employee.

Practice Online


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

Previous: Write a query to get the total salaries payable to employees.
Next: Write a query to get the maximum salary of an employee working as a Programmer.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/postgresql-exercises/aggregate-function-and-groupby/aggregate-function-and-groupby-exercise-3.php