SQL & PostgreSQL interview practice.
Rehearse with explained interview questions. Describe the mechanism, trace an example, and explain a trade-off before revealing the answer.
How to use this session
- Choose a level and session length. Try each prompt before opening the notes.
- Compare your explanation with the source answer and revisit any concept you missed.
- Mark the questions you reviewed. Sign in to save session history; your draft answers stay in this page.
Code is provided for reading and tracing. These sessions do not execute or automatically grade code.
SQL & PostgreSQL practice
Think first. Reveal second.
Explain your reasoning before opening the notes. A focused session lets you choose your question count; mock rounds follow the original guide.
Loading your question pool…
Preview the SQL & PostgreSQL question pool
- WHERE vs HAVING: what is the difference?
WHERE filters individual rows before groups are built, while HAVING filters the groups produced by aggregation. They exist at different logical stages of a query. Use WHERE for conditions on source rows and HAVING for conditions such as “the group's total is greater than 1000.”
- What is the difference between the join types?
A join combines rows from two table expressions according to a relationship or condition. Inner joins keep matching pairs, while outer joins also keep unmatched rows from specified sides with NULL values for the missing side. The correct join type follows the business requirement about which records must remain visible.
- Why does my join return duplicate rows?
A join returns one output row for each matching combination, so repeated parent values are often the correct result of a one-to-many relationship. Unexpected duplicates usually mean the query's relationship or desired result level was misunderstood. The fix is to align the join or aggregation with whether the output should represent a customer, an order or an order item.