# SQL Interview Practice

> SQL interview practice questions ranked by interview frequency and seniority, with multi-seed Postgres grading for data engineer prep.

Canonical URL: <https://datadriven.io/sql-interview-practice>

Breadcrumb: [Home](https://datadriven.io/) > [SQL Interview Practice](https://datadriven.io/sql-interview-practice)

## Summary

SQL interview practice ranked by how often each question shows up in real data engineering loops, from L3 warm-ups to L6 optimization rounds. Every problem submits to live Postgres 16 with 10-seed grading. Pulled from verified interview reports, with the approach, the typical wrong answer, and the follow-up the interviewer asks next.

## What this page covers

SQL interview practice is most useful when it separates the gym from the game. Problems mode is the gym: self-paced, a clear prompt, instant grader feedback. Interview mode is the game: a vague prompt, a timer, follow-ups, and a verdict. Most candidates over-invest in problems mode and walk into their first onsite having never defended a query out loud, then lose points on the communication row of the rubric rather than on correctness.

The questions map to seniority. L3 (junior) is the warm-up band: INNER versus LEFT JOIN, GROUP BY with HAVING. L4 (mid) is the bulk of every loop: window dedup, CTE chains, conditional aggregation, gaps-and-islands, top-N per group. L5 (senior) is defended out loud: LAG sequence patterns, retention cohorts, NULL traps where NOT IN against a nullable subquery silently returns empty, late-arriving and out-of-order data with event_time versus ingest_time. L6 (staff) is occasional but rewarding: reading an EXPLAIN plan to classify a full table scan, and surfacing silent data-quality regressions across a fact table with a rolling baseline on row count, null rate, and key cardinality.

How the round flows. A 45-minute round opens with one Easy or Medium warm-up to get the candidate typing, then moves into one Medium-to-Hard problem where the follow-ups push on edge cases, dialect choices, and runtime cost. The follow-ups carry as much weight as the initial query: volunteering that NULLIF prevents the first-row crash before being asked separates senior from mid; writing a query that runs but stalling on why ROW_NUMBER over RANK lands the other way. With one week before a loop, the five highest-leverage patterns to drill are dedup-latest, conditional aggregation, gaps-and-islands, sessionization, and top-N per group. Run two or three timed mock interviews against a real warehouse in the week before an onsite to change how the live round feels.

## Frequently asked questions

### Which SQL topics show up most in interviews?

Aggregation is the largest single bucket, joins next, window functions third. The four sub-areas to drill: window functions, CTEs, gaps-and-islands, and aggregation with HAVING. A typical 45-minute round mixes two or three in one problem.

### How many SQL questions should I work through before an onsite?

About 80 if you solve them properly. Quality over count. A question you wrote, ran, debugged, and could re-derive a week later is worth 10 you skimmed. The signal you are ready is writing a Medium window-function question in under 12 minutes without looking up syntax.

### What is the difference between practicing problems and practicing the interview?

Problems mode is self-paced with a clear prompt and instant grader feedback. Interview mode adds a vague prompt, a timer, follow-ups, and a verdict. You need both. Most candidates over-invest in problem mode and have never defended a query out loud before their first onsite.

### Are these questions from real interviews?

Yes. Each is paraphrased from verified interview reports submitted by data engineer candidates after their loops, deduplicated and rewritten so the shapes match without copying specific prompt text.

### What SQL dialect are answers written in?

Postgres 16. Dialect-specific syntax (QUALIFY, FILTER, lateral joins) is called out when relevant. About 85 percent of the patterns transfer cleanly to Snowflake, BigQuery, Redshift, and MySQL.

### How is this different from LeetCode SQL?

LeetCode is puzzle-shaped: clever self-joins, NULL gotchas, one-liners. Data engineering interviews are pipeline-shaped: dedup, sessionize, chain CTEs to produce a reportable number. Both can be hard; the kind of hard is different.

## Related practice catalogs

- [SQL interview questions catalog](https://datadriven.io/sql-interview-questions): The full 905-problem catalog organized by the eight patterns that cover 90 percent of rounds, with worked-solution prose.
- [Live SQL mock interview](https://datadriven.io/mock-interview/sql): A timed 45-minute mock against a real warehouse with an AI interviewer pushing on tradeoffs and follow-ups.
- [SQL practice problems](https://datadriven.io/sql-practice-problems): The open problem catalog with browser editor, schema panel, and the 10-seed grader.
- [Window functions practice](https://datadriven.io/sql-window-functions-interview-questions): The single most-tested topic in data engineer SQL rounds, isolated with engineered ties.

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.