pg_exercises=# SELECT DISTINCT salary
pg_exercises-# FROM employees a
pg_exercises-# WHERE 3 >= (SELECT COUNT(DISTINCT salary)
pg_exercises(# FROM employees b
pg_exercises(# WHERE a.salary >= b.salary)
pg_exercises-# ORDER BY a.salary DESC;
salary
---------
2400.00
2200.00
2100.00
(3 rows)
Sample table: employees
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer