21 PostgreSQL problems, solved step by step.
SQL interview problems in our own words, each solved in PostgreSQL with queries you can run on the page against the real engine. No setup, no signup.
- Combine Two TablesEasy
- Employees Earning More Than Their ManagersEasy
- Customers Who Never OrderEasy
- Duplicate EmailsEasy
- Delete Duplicate EmailsEasy
- Recyclable and Low Fat ProductsEasy
- Classes More Than 5 StudentsEasy
- Game Play AnalysisEasy
- Rising TemperatureEasy
- Second Highest SalaryMedium
- Nth Highest SalaryMedium
- Department Highest SalaryMedium
- Consecutive NumbersMedium
- Rank ScoresMedium
- Customers Who Bought All ProductsMedium
- Product Sales AnalysisMedium
- Managers with at Least 5 Direct ReportsMedium
- Exchange SeatsMedium
- Department Top Three SalariesHard
- Trips and UsersHard
- Human Traffic of StadiumHard
Coding problems, explained
Are these the official problem statements?
No. Every statement, example and test value here is written by us. The problem names are the common ones people search for, and the solutions explain the standard approaches from brute force to optimal.
Can I run the solutions?
Yes. Every approach is a complete program with a Run button that executes it on the CompileBytes engine. Edit the code and run it again to try your own inputs.
Is there a judge or a submit button?
No. These are worked solutions to read and run, not a graded test. To practise, open the compiler from any problem and write your own version before reading the answers.
Is this free? Do I need an account?
Every problem is free to read, run, edit and copy. No account is required.