SQL Exercises

PostgreSQL: Advanced SQL Subqueries Exercises

0 Exercises
~0 min

This guide is specifically for PostgreSQL syntax.

Advanced-level SQL Subqueries practice exercises with solutions.

Exercise 1

Question: Find the second highest salary in the company.

SELECT MAX(salary) AS second_highest FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);

Nested subqueries can solve complex problems. Here we find the max salary that is less than the overall max.


PostgreSQL-Specific Notes

This page covers PostgreSQL syntax. Other databases may have different syntax for similar operations.

Related Content

From Our Blog

Ready for more practice?

Join SQL Mastery and get access to interactive exercises, quizzes, and more.