PostgreSQL Aggregate Functions and Group By: Get the difference between the highest and lowest salaries
8. Write a query to get the difference between the highest and lowest salaries.
SELECT MAX(salary) - MIN(salary) DIFFERENCE FROM employees;
Sample table: employees
pg_exercises=# SELECT MAX(salary) - MIN(salary) DIFFERENCE pg_exercises-# FROM employees; difference ------------ 21900.00 (1 row)
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?