SQL Interview Questions and Answers for Data Engineers (2026)
The SQL interview questions that actually repeat in a 2026 data engineering screen, each with a one-line answer and the follow-up that decides it — joins and aggregation, window functions, deduplication, data modeling and the warehouse — plus the concepts every round drills: SQL vs NoSQL, indexing, and partitioning. A framework-first prep guide for data engineers heading into SQL tech screens.
October 6, 202617 min read

SQL Interview Questions: the 2026 shortlist for data engineers
Most SQL prep goes wide and shallow — a hundred queries copied from a cheat sheet, none of them defended out loud. That is the opposite of how a real screen works. A data engineering SQL round reuses a small set of patterns, and inside each one the interviewer reaches for the same handful of follow-ups: what is the grain of this table, what happens to the row that has no match, is your count still right when a duplicate sneaks in.
This is the shortlist of SQL interview questions that actually repeats in 2026 — grouped the way a tech screen groups them, each with a one-line answer and the follow-up that decides whether you pass. It is written for the people who get these rounds most: data engineers facing timed SQL screens, so it leans into the patterns that separate a junior answer from a senior one, including the SQL window functions that show up in almost every mid-to-senior loop. Before the list, there is a five-step framework that answers a query you have never seen, because the method is worth more than any single solution. Read it as a map — the query is table stakes, and the round is won on what you say when someone asks "why that join, and not the other one?"
How a data engineering SQL screen is actually run
A SQL screen is not a written exam. It is a 30-to-60-minute working session where a schema and an expected output sit beside the editor, you write a query against sample rows, run it, and defend each clause while the interviewer digs. In most data engineering interview questions of this kind you get three to six prompts on one schema — the Meta-style tech screen, for example, runs three SQL and three Python questions in 60 minutes — so pace matters as much as correctness. The same five moves carry every prompt on this list, so learn the moves first.
The five-step framework that answers any SQL question
- Read the schema. Before writing anything, name the tables, the keys, and which column joins to which. Thirty seconds here saves a wrong join later.
- Clarify the grain. Say out loud what one row of your result means — "one row per customer per month." Half of all wrong answers are really the wrong grain.
- Build in layers. Filter first, aggregate second, window or join last. A CTE per step reads better than one nested query and is easier to defend.
- Verify on sample rows. Run it, then trace two or three rows by hand against the expected output. Catch the off-by-one before the interviewer does.
- Say the tradeoff. Name the cost — a full scan, a fan-out join, a window over an unpartitioned table — and what you'd change at a billion rows.
On a live round the interviewer rarely waits for a clean query before asking "what's the grain of that result?" or "what happens to customers who never ordered?" That is the part a copied solution can never rehearse — and the part these questions are really testing.
What the debrief measures
Whatever the prompt, the scorecard is the same four dimensions: Correctness (does the query return the expected rows?), Query reasoning (did you pick the right join and grain, not just one that runs?), Communication (do you narrate the plan before you type?), and Time management (do you finish three prompts, not one perfect one?). Keep these in mind as you work the list — every question below maps back to them.
The questions, by category
The shortlist splits into five groups. The warm-ups check that you can join and aggregate without fumbling the grain; window functions are the senior signal; deduplication and data-quality questions are the DE bread-and-butter; modeling questions test whether you think in facts and dimensions; and the concept questions show up as follow-ups inside every single one.
| Group | Focus | What it tests |
|---|---|---|
| A. Joins & aggregation | The warm-ups | Grain, join type, GROUP BY / HAVING |
| B. Window functions | The senior signal | Ranking, running totals, period-over-period |
| C. Dedup & data quality | DE bread-and-butter | Finding and dropping duplicates, trusting counts |
| D. Data modeling & warehouse | The design round | Facts, dimensions, SCDs, ETL vs ELT |
| E. Concepts every screen | The follow-ups | SQL vs NoSQL, indexing, partitioning, normalization |
Group A — Joins & aggregation (the warm-ups)
These open almost every screen. Each is one primitive done cleanly, and each reappears as a step inside the harder window and modeling questions — so nailing them pays off twice. The trap is never the syntax; it is the grain and the join type.
| # | Question | The answer in one line | The follow-up that decides it |
|---|---|---|---|
| 1 | Total and average sales per customer | GROUP BY customer_id, aggregate, order by the metric | "A customer with zero orders — do they appear with 0 or vanish?" |
| 2 | Customers who never ordered | LEFT JOIN orders, keep rows where the order key IS NULL | "Why LEFT JOIN ... IS NULL and not NOT IN?" |
| 3 | Filter on an aggregate (e.g. 3+ orders) | HAVING count(*) >= 3, not WHERE | "Why can't you put that count in the WHERE clause?" |
| 4 | Orders with their customer details | INNER JOIN on customer_id | "A customer row is missing — do you want to drop those orders or keep them?" |
| 5 | Revenue by category, including empty categories | LEFT JOIN from category to sales, COALESCE the sum to 0 | "Where do the NULLs come from, and which side do you join from?" |
The two answers people fumble are the NULL ones. "Customers who never ordered" is the classic:
SELECT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.customer_id
WHERE o.customer_id IS NULL;
Say why out loud: a LEFT JOIN keeps every customer and leaves order columns NULL when there is no match, so the IS NULL filter is exactly the unmatched set. NOT IN looks equivalent until the subquery returns a single NULL, which silently drops every row — a favourite follow-up precisely because it separates people who memorised the pattern from people who understand three-valued logic.
The moment you write GROUP BY, a good interviewer asks what one row of your output means. If you can answer "one row per customer, summed across all their orders" without looking, you are already ahead of half the field.
Group B — Window functions (the senior signal)
If one topic decides a data engineering SQL screen, it is this one. SQL window functions let you rank, run totals, and compare a row to its neighbours without collapsing the result — and the interviewer uses them to tell a junior answer from a senior one. Expect at least one, usually two.
| # | Question | The answer in one line | The follow-up that decides it |
|---|---|---|---|
| 6 | Top N per group (e.g. top 3 products per category) | ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC), filter <= 3 | "Ties on the 3rd spot — ROW_NUMBER, RANK, or DENSE_RANK?" |
| 7 | Running / cumulative total | SUM(x) OVER (ORDER BY date ROWS UNBOUNDED PRECEDING) | "What does the default window frame do, and when does it bite you?" |
| 8 | Month-over-month change | LAG(metric) OVER (ORDER BY month), subtract | "First month has no prior — what does LAG return, and how do you handle it?" |
| 9 | Nth highest value (e.g. 2nd highest salary) | DENSE_RANK() OVER (ORDER BY salary DESC), filter = 2 | "With duplicates, does 'second highest' mean the second distinct value?" |
| 10 | Median / percentile per group | PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x) or a windowed split | "No percentile function — how do you get the median with pure window functions?" |
"Top N per group" is the one to have automatic:
SELECT category, product, sales
FROM (
SELECT category, product, sales,
ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC) AS rn
FROM product_sales
) ranked
WHERE rn <= 3;
The follow-up is always about ties. Narrate the difference before you are asked: ROW_NUMBER gives every row a distinct number so you always get exactly three even if two tie; RANK leaves gaps after a tie (1, 2, 2, 4); DENSE_RANK does not (1, 2, 2, 3). Which you pick is a product decision — "do two equal sellers both count as top-3?" — and saying that out loud is the senior signal.
Group C — Deduplication & data quality
This group is why data engineers get their own SQL screen. Real tables have duplicate rows, late-arriving records, and nulls where you did not expect them, and the interviewer wants to see you find them and reason about whether your numbers can be trusted.
| # | Question | The answer in one line | The follow-up that decides it |
|---|---|---|---|
| 11 | Find duplicate rows | GROUP BY the business key, HAVING count(*) > 1 | "What is the business key here — is it one column or three?" |
| 12 | Keep the latest row per key (deduplicate) | ROW_NUMBER() OVER (PARTITION BY key ORDER BY updated_at DESC), keep = 1 | "Two rows share the exact same timestamp — which one wins?" |
| 13 | Count distinct vs count | COUNT(DISTINCT col) vs COUNT(col) vs COUNT(*) | "Why do these three return different numbers on a column with nulls?" |
| 14 | Detect gaps in a sequence (missing dates) | A calendar / numbers table LEFT JOINed to the data | "Where do you get the complete date spine from?" |
| 15 | Spot fan-out from a bad join | Compare row counts before and after the join | "Your revenue doubled after a join — what happened and how do you prove it?" |
Deduplication is the one you will almost certainly write:
WITH ranked AS (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY order_id ORDER BY updated_at DESC) AS rn
FROM orders_raw
)
SELECT * FROM ranked WHERE rn = 1;
The follow-up — "two rows with the same timestamp" — is the real test. There is no right answer, only a defended one: add a deterministic tiebreaker to the ORDER BY (a surrogate key, the ingestion file name) so the result is stable across re-runs. "Stable across re-runs" is the phrase that tells the interviewer you have actually run a pipeline, not just a query.
Interviewers love the "is your count still correct?" family because it separates people who return a number from people who can say why they trust it. If you can explain how a fan-out join inflated a sum and how a row-count check catches it, you are speaking like someone who has been paged at 2am for a doubled metric.
Group D — Data modeling & the warehouse
Past the query questions, most DE loops include a data modeling interview segment — sometimes on a canvas where you add tables, draw relationships, and export the SQL. These test whether you think in facts and dimensions, and they are where ETL interview questions live too.
| # | Question | What to be able to say | The follow-up that decides it |
|---|---|---|---|
| 16 | Star schema vs snowflake | One central fact table, denormalized dimensions around it; snowflake normalizes those dimensions | "When is the extra join of a snowflake worth it?" |
| 17 | Design a fact table (e.g. orders) | One row per business event, foreign keys to dimensions, additive measures | "What's the grain of this fact, and is revenue additive across every dimension?" |
| 18 | Slowly changing dimension (SCD type 2) | Keep history with valid_from / valid_to and a current flag, not an in-place update | "A customer changes city — walk me through the rows before and after." |
| 19 | ETL vs ELT | ETL transforms before load; ELT loads raw then transforms in the warehouse | "Why did ELT win for most cloud warehouses?" |
| 20 | Idempotent backfill | A re-run for the same date produces the same table — delete-insert or MERGE on the partition | "The job runs twice for yesterday — do you get double rows?" |
There is rarely one query to write here; the signal is vocabulary and tradeoffs. The phrase that lands is grain: say "this fact is one row per order line, revenue is additive across time, product, and store, but a ratio like margin is not" and you have shown more modeling sense than a page of DDL. For SCD type 2, be ready to narrate the row history out loud — the old row gets its valid_to stamped and its current flag cleared, a new row opens with today's valid_from — because the interviewer will ask you to trace exactly that.
Group E — Concepts drilled in every screen
These are not "write a query" prompts — they are the tradeoffs an interviewer drills the instant you mention a table or an index. Expect at least two inside any screen above.
| # | Concept | What to be able to say | Where it shows up |
|---|---|---|---|
| 21 | SQL vs NoSQL | Pick by access pattern and consistency need — SQL for joins and strong consistency, NoSQL for known-key reads at scale | Every "where would you store this?" |
| 22 | Indexing | An index trades write speed and storage for faster reads on selective predicates | "This query is slow — what index, and why not index everything?" |
| 23 | Partitioning vs sharding | Partitioning splits one table by a key (often date) for pruning; sharding splits across machines | "What partition key, and how do you avoid a hot partition?" |
| 24 | Normalization vs denormalization | Normalize for integrity in OLTP, denormalize for read speed in the warehouse | "Why is the warehouse fact table happily denormalized?" |
For SQL vs NoSQL, the answer that fails is "NoSQL is faster." The answer that passes ties it to the workload: a transactional system with multi-table joins and strict consistency wants a relational database; a high-volume lookup by a known key — a session store, a feature cache — is where a key-value or document store earns its place. Say the access pattern first and the technology second, and the follow-up disappears.
How to prepare: a two-week plan
You do not need a hundred queries memorized. You need the framework automatic, window functions fluent, and a handful of data-quality patterns you can defend under pressure. Here is a realistic two-week pass.
- Days 1–3: Drill Group A until grain and join type are reflexive. Write each answer, then say its grain out loud in one sentence.
- Days 4–8: Live in window functions.
ROW_NUMBERfor top-N and dedup,RANK/DENSE_RANKfor ties,LAG/LEADfor period-over-period, and one running total. These are the highest-leverage days. - Days 9–11: Deduplication and data quality, plus the Group D modeling vocabulary — grain, star schema, SCD type 2, idempotent backfill. Write two-sentence answers out loud.
- Days 12–14: Full timed screens — three to six prompts on one schema, clock running, no notes. The goal is to finish on pace while narrating each step.
The most common mistake in the last week is reading more solutions. By day 12 reading is not the bottleneck — speaking is. If you have never said "I'd dedup with ROW_NUMBER partitioned by order_id, latest updated_at first, with a surrogate-key tiebreaker" out loud to a prompt, do that before you solve another query on paper. If you want more raw problems to drill the queries themselves, PipeCode is a sister platform built for exactly that; use it for volume, then come back here to rehearse defending them.
The follow-ups that decide every SQL round
Scan the right-hand column of every table above and a pattern jumps out: the questions rhyme. Master these five cross-cutting follow-ups and you are ready for prompts that are not even on this list.
- "What's the grain of this result?" → One sentence: what one row means. Get this wrong and the whole query is wrong.
- "What happens to the row with no match / a NULL?" →
LEFT JOINplusIS NULL,COALESCEfor defaults, and theNOT INtrap. - "Ties —
ROW_NUMBER,RANK, orDENSE_RANK?" → Tie it to the product question: do equal rows share a place or not? - "Is your count still correct?" →
COUNT(DISTINCT)vsCOUNT, dedup with a deterministic tiebreaker, a row-count check around every join. - "Now it's a billion rows — what breaks?" → Name the cost: a full scan, a window over an unpartitioned table, a fan-out join; then the fix: a partition key, an index, pre-aggregation.
Each of these maps straight to the debrief: do you pick the right grain and join (query reasoning), return the expected rows (correctness), narrate the plan (communication), and finish on pace (time management)? Reading this list teaches you the answers. It does not teach you to deliver them while someone pushes back — that only comes from saying them out loud.
Frequently asked questions
What are the most common SQL interview questions for data engineers in 2026?
The repeat offenders are joins with the right grain, aggregation with GROUP BY / HAVING, top-N-per-group and running totals with window functions, and deduplication. On top of those, data engineering screens add modeling vocabulary — star schema, fact grain, slowly changing dimensions — and a layer of concept follow-ups like SQL vs NoSQL and indexing. Prepare the window functions and the data-quality patterns deeply; they decide more rounds than any single query.
How do I answer a SQL interview question I've never seen?
Fall back on the five-step framework: read the schema, clarify the grain, build the query in layers, verify on sample rows, then say the tradeoff. Most novel prompts decompose into patterns you already know — a filtered aggregate, a windowed ranking, a dedup — so you are rarely starting from zero. Narrating the plan before you type also buys you thinking time and scores on communication.
Are window functions really asked in data engineering interviews?
Yes — they are the single highest-signal topic in a mid-to-senior SQL screen. Expect at least one window-function question and often two: top-N per group with ROW_NUMBER, a running total, a month-over-month change with LAG, or an Nth-highest with DENSE_RANK. The follow-ups almost always probe ties and the default window frame, so be ready to explain ROW_NUMBER vs RANK vs DENSE_RANK without looking it up.
SQL vs NoSQL — what should I say in a data engineering interview?
Lead with the access pattern, not the technology. A workload with multi-table joins, ad-hoc analytics, and strong consistency wants a relational database; a high-volume read by a known key — a cache, a session store, a document lookup — is where NoSQL earns its place. Avoid "NoSQL is faster"; the correct framing is that each trades different guarantees, and you choose by how the data is written and read. That one move usually ends the follow-up.
How do I practice SQL interview questions out loud?
Reading a solution isn't the same as defending it while someone interrupts. On Zynter, the data engineering rounds are live voice screens — the schema and expected output sit beside the editor, your query runs against sample rows, and a voice interviewer asks the follow-ups above one at a time, then gives you a debrief on correctness, query reasoning, communication, and time management. The rounds are modelled on how real company loops run, and the score is a practice signal, not a hiring decision.
How long does it take to prepare for a SQL or data engineering screen?
With focused practice, about two weeks gets you dangerous and four to six weeks comfortable, assuming you already know basic joins and aggregation. Depth beats breadth: fluency in window functions and a few defended data-quality patterns is worth more than skimming a hundred queries. Spend the back half of your prep on timed, out-loud mock screens rather than more reading.
Practise it on Zynter
You can read every answer. The screen is won on the follow-ups.
Pick a data engineering round, write SQL against a real schema, and defend it out loud to a voice interviewer that keeps asking "what's the grain?" and "is your count still right?" — then read the debrief. Zynter.ai is on-demand mock interviews for real company loops, with 150+ rounds across 20 companies including Meta, DoorDash, Airbnb, Netflix and Uber data engineering screens (Sep 2026).
Practise a data engineering round → Browse all interview tracksAlmost nobody freezes on the code. They freeze on the follow-up.
Answer a real round to a voice interviewer that keeps asking why. No scheduling, no subscription, first session ready in under a minute.
