SQL interview questions, with the traps explained
Each one has a small table and a query that looks right. Run it in your browser, find the trap, fix it. Free, no sign-up.
- Find the second highest salary in SQL
The classic SQL interview question, and the tie that breaks LIMIT 1 OFFSET 1. Try it in your browser, then see the answer and why.
- SQL self join: employees who earn more than their manager
A self join interview question with a classic trap: joining the table to itself the wrong way round. Try it, then see the answer.
- SQL: find customers who never placed an order (and the NOT IN trap)
Why NOT IN can return nothing when the list has a NULL, and two safe ways to find customers with no orders. Try it in your browser.