Rounds 1–5
Each round is scored out of 100 using the global rubric. Suggested interview format: 35 minutes questions, 10 minutes follow-ups, 5 minutes self-review.
Round 1 — SQL Beginner
Questions
- Explain database vs DBMS vs PostgreSQL vs SQL.
- Write a query returning the 10 newest paid orders with deterministic ordering.
- Explain
NULL,IS NULL, and why= NULLfails. - Compare primary key, unique constraint, and foreign key.
- Given customers and orders, return customers with no orders.
Strong-answer checkpoints: declarative SQL, three-valued logic, ORDER BY created_at DESC,id DESC, NOT EXISTS, keys as invariants rather than “indexes.”
Scoring emphasis: correctness 40, terminology/mental model 25, SQL readability 20, explanation 15.
Fail conditions: claims row order is automatic; uses = NULL; says FK is “just a join”; cannot distinguish database from DBMS.
Follow-up: Why should duplicate-email prevention use a unique constraint even if the API validates first?
Round 2 — SQL Intermediate
Questions
WHEREvsHAVING; show one query using both.- INNER vs LEFT JOIN; explain ON-vs-WHERE outer-join trap.
- Return top two orders per customer using a window function.
- Compare
EXISTS,IN, andNOT EXISTS; explain theNOT INNULL trap. - Write keyset pagination for
(created_at,id)and propose an index.
Strong-answer checkpoints: output grain/cardinality, row_number, null-safe anti-join reasoning, compound cursor, index aligned with equality + ordering.
Scoring emphasis: SQL correctness 35, result-grain reasoning 25, alternatives 20, performance awareness 20.
Follow-up: When might LATERAL beat the window solution for top-N-per-parent?
Round 3 — SQL Advanced
Questions
- Solve sessionization with a 30-minute inactivity gap.
- Write monthly cohort retention and state denominator semantics.
- Explain recursive CTE anchor/recursive term/cycle handling.
- Compare CTE inlining,
MATERIALIZED, andNOT MATERIALIZED. - Design an atomic inventory decrement and explain its concurrency behavior.
Strong-answer checkpoints: lag + cumulative session flag, distinct activity periods, recursion termination, plan-driven CTE choice, conditional UPDATE + affected-row result.
Scoring emphasis: correctness 30, advanced SQL mechanics 25, edge cases 20, concurrency/performance 25.
Follow-up: How would late-arriving events change a retention report?
Round 4 — Joins + Aggregates
Questions
- Why can joining orders→items→products make revenue totals wrong?
- Return customer lifetime value including customers with zero orders.
- Explain semi-join and anti-join use cases.
- Compare
GROUP BY, window aggregates,ROLLUP, andGROUPING SETS. - Given a 100× cardinality estimate error in a join plan, what do you inspect?
Strong-answer checkpoints: define result grain before aggregation, avoid DISTINCT-as-bandage, outer join + aggregate semantics, MCV/dependencies/statistics, join multiplicity.
Scoring emphasis: data correctness 35, relational reasoning 25, planner awareness 25, communication 15.
Follow-up: Why can a foreign key help data correctness without automatically making the join fast?
Round 5 — Window Functions
Questions
row_numbervsrankvsdense_rankwith a salary tie example.- Explain PARTITION BY, window ORDER BY, and frame as separate concepts.
- Why is
last_valuecommonly wrong without an explicit frame? - Write a running balance with deterministic ties.
- Compare ROWS, RANGE, and GROUPS; give a workload for each.
Strong-answer checkpoints: peer semantics, explicit ROWS UNBOUNDED PRECEDING, full-partition last-value frame, tie-breakers, distinction between row-count and value/peer-group frames.
Scoring emphasis: window semantics 45, query correctness 25, edge cases 20, communication 10.
Follow-up: Write top-three distinct salaries per department including ties.