- Data engineer interviews weight SQL toward pipeline work (window functions, incremental loads, deduplication) rather than reporting queries.
- Practice window functions first: ROW_NUMBER, LAG and running totals appear in deduplication, sessionization and change detection questions.
- Pipeline questions test watermark-based incremental loads, idempotent MERGE logic and backfills scoped to the affected partitions.
- For late-arriving data, ask which column decides which record supersedes another before you write the query.
- Live rounds are scored on clarifying questions, stated assumptions, explained trade-offs and a working final query.
Which SQL topics do data engineer interviews actually test?
Data engineer interviews weight SQL toward pipeline work, not dashboard work. Analyst interviews lean on joins, aggregations and reporting queries. Data engineering roles add window functions, incremental logic, deduplication and debugging queries that broke in production. If your practice time mirrors analyst work, you are studying the wrong half of the exam.
SQL is still the shared language of the job. In the 2026 Stack Overflow Developer Survey, SQL is used by 58% of respondents, level with Python, and the pattern holds whether you interview in New York, London, Paris or Dakar: the interviewer wants to see that you can move data safely, not just summarize it.
Reporting queries vs pipeline queries: the split that matters
| Topic | Analyst reporting focus | Data engineer pipeline focus |
|---|---|---|
| Window functions | Ranking in a report | ROW_NUMBER for dedup, running totals over event streams |
| Joins | One-off reporting joins | Late-arriving data, incremental merge conditions |
| Aggregation | GROUP BY for a chart | Detecting duplicates across batches |
| Debugging | Fixing a wrong number | Tracing which pipeline step produced the wrong rows |
Where to spend your first 10 hours
Put roughly half your time on window functions, because they show up in deduplication, incremental loads and change detection at once. The PostgreSQL window functions reference covers ROW_NUMBER, LAG and the frame syntax you will be asked to reason about. Spend the rest on deduplication and late-arriving data. If you are coming from an analyst role, our guide to the data analyst career path explains where data engineering fits as a next step.
How do you practice window functions for data engineering interviews?
Window functions appear in nearly every data engineer interview because they map directly to pipeline work: running totals, deduplication and sessionization. Practice these three questions against a rubric, not an answer key.
Question 1: a running total that resets every month
Given a table of daily orders, compute a cumulative revenue total that restarts each month.
SELECT
order_date,
order_id,
revenue,
SUM(revenue) OVER (
PARTITION BY date_trunc('month', order_date)
ORDER BY order_date, order_id
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS month_to_date_revenue
FROM daily_orders;Rubric: correct partition and ordering, no correlated subquery, ties handled explicitly. Common failure mode: ordering by a non-unique column. With an ORDER BY and no frame clause, PostgreSQL uses a default frame that includes every row tied with the current one, as its documentation on window frames explains, so two orders on the same day get the same running total. Add a tiebreaker (here, order_id) and an explicit ROWS frame before you optimize anything else.
Question 2: keep the latest event per user
Deduplicate an events table by keeping only the most recent row for each user_id.
WITH ranked AS (
SELECT
e.*,
ROW_NUMBER() OVER (
PARTITION BY user_id
ORDER BY updated_at DESC, event_id DESC
) AS rn
FROM events AS e
)
SELECT *
FROM ranked
WHERE rn = 1;Rubric: chooses ROW_NUMBER over a self-join, filters on the computed column, and can explain that RANK would keep both rows when two events share the same updated_at. Common failure mode: forgetting the deterministic tiebreaker, so the "latest" row changes from one run to the next. On Snowflake, BigQuery or Databricks you can replace the CTE with a QUALIFY clause; PostgreSQL does not support it, so say which engine you are writing for.
Question 3: sessionize an event stream
Assign a session number to each event, starting a new session when the gap since the previous event exceeds 30 minutes.
WITH ordered AS (
SELECT
user_id,
event_ts,
LAG(event_ts) OVER (PARTITION BY user_id ORDER BY event_ts) AS prev_ts
FROM events
),
flagged AS (
SELECT
*,
CASE
WHEN prev_ts IS NULL OR event_ts - prev_ts > INTERVAL '30 minutes' THEN 1
ELSE 0
END AS is_new_session
FROM ordered
)
SELECT
user_id,
event_ts,
SUM(is_new_session) OVER (
PARTITION BY user_id
ORDER BY event_ts
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS session_number
FROM flagged;This is the question that separates data engineering from reporting, because it chains three ideas: LAG to get the previous timestamp, a CASE to flag the start of a session, and a running SUM that turns those flags into session numbers. Rubric: uses LAG rather than a self-join, handles the first event of each user (prev_ts is NULL), and accumulates flags with an explicit frame. Common failure mode: jumping straight to a self-join on timestamps, which explodes on large event streams.
What SQL questions test pipeline and ETL thinking rather than reporting?
Reporting questions ask you to aggregate a static table. Pipeline questions ask you to move data without breaking it. These three are the ones interviewers use to tell the difference.
Question 4: an incremental load with a watermark
"Yesterday's table has 10 million rows. New events landed overnight. Write a query that appends only the new ones."
INSERT INTO events_clean (event_id, user_id, event_type, event_ts, ingested_at)
SELECT event_id, user_id, event_type, event_ts, ingested_at
FROM raw_events
WHERE ingested_at > (SELECT last_loaded_at FROM etl_watermarks WHERE table_name = 'events_clean')
AND ingested_at <= (SELECT run_started_at FROM etl_runs WHERE run_id = 'current');
UPDATE etl_watermarks
SET last_loaded_at = (SELECT run_started_at FROM etl_runs WHERE run_id = 'current')
WHERE table_name = 'events_clean';The interviewer is checking whether you keep a high-water mark, usually the latest ingestion timestamp or ID from the last successful run, and filter on it. Notice the closed upper bound: the load stops at the moment the run started, so rows that arrive while the job is running are picked up next time instead of being skipped. Common failure mode: scanning the full source table, or filtering on a business timestamp such as updated_at that can change during the load and silently drop rows.
Question 5: make a load idempotent
"Your job ran twice by accident. Show that the target table is still correct."
MERGE INTO dim_customers AS t
USING (
SELECT *
FROM (
SELECT
s.*,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY updated_at DESC) AS rn
FROM staging_customers AS s
) AS d
WHERE rn = 1
) AS src
ON t.customer_id = src.customer_id
WHEN MATCHED AND src.updated_at > t.updated_at THEN
UPDATE SET email = src.email, plan = src.plan, updated_at = src.updated_at
WHEN NOT MATCHED THEN
INSERT (customer_id, email, plan, updated_at)
VALUES (src.customer_id, src.email, src.plan, src.updated_at);What they are really testing: do you know that a plain INSERT duplicates everything on a rerun, and that a MERGE on a unique key makes reruns safe? Two details earn extra credit. First, the source is deduplicated before the merge: in Snowflake, when several source rows match the same target row, the MERGE documentation explains that the statement fails by default, so a messy staging table breaks the job. Second, the WHEN MATCHED condition only updates when the incoming row is newer, which protects you from replaying old data. Common failure mode: reasoning about a single run instead of designing for reruns.
Question 6: a backfill without double-counting
"The definition of net revenue changed two months ago. Rewrite history without duplicating rows that are already loaded."
BEGIN;
DELETE FROM fact_orders
WHERE order_date BETWEEN DATE '2026-09-01' AND DATE '2026-10-31';
INSERT INTO fact_orders (order_id, order_date, customer_id, net_revenue)
SELECT order_id, order_date, customer_id, gross_amount - discount - refund AS net_revenue
FROM orders_source
WHERE order_date BETWEEN DATE '2026-09-01' AND DATE '2026-10-31';
COMMIT;They want a delete-then-insert or a merge scoped to the affected partitions, inside a transaction, not a full reload of the table. Say out loud how you would validate it: row counts and revenue totals per day, before and after. Common failure mode: reprocessing the whole history, which signals you have never owned a pipeline with a cost or an SLA attached.
How do you write SQL to deduplicate and handle late-arriving data?
Question 7: deduplicate with late corrections in mind
The prompt: a table of sensor readings arrives with duplicates, and corrections can land hours after the original row. Write the query that keeps the right version.
The naive answer partitions by sensor_id, orders by timestamp and keeps row 1. It fails because it assumes the latest row is the correct one. A correction usually describes the same reading as the original, with the same reading timestamp, and carries a higher correction sequence. Ordering by time deletes the fix.
WITH ranked AS (
SELECT
r.*,
ROW_NUMBER() OVER (
PARTITION BY sensor_id, reading_ts
ORDER BY correction_seq DESC, ingested_at DESC
) AS rn
FROM sensor_readings AS r
)
SELECT sensor_id, reading_ts, value, correction_seq
FROM ranked
WHERE rn = 1;The rubric rewards candidates who ask one question before writing anything: which column tells me which record supersedes another? If the answer is a version or sequence number, the partition becomes the natural key of the reading (sensor and reading time) and the ordering key becomes the version. If you cannot get an answer, state your assumption out loud. That habit, more than the syntax, is what separates candidates who pass.
Question 8: retract and restate a fact
A downstream table says a customer's plan is Premium. A correction arrives: it was never Premium, it was Starter. Write SQL that retracts the old fact and records the new one without erasing history.
BEGIN;
UPDATE customer_plan_history
SET valid_to = TIMESTAMP '2026-11-27 09:00:00', is_current = FALSE
WHERE customer_id = 4821 AND is_current = TRUE;
INSERT INTO customer_plan_history (customer_id, plan, valid_from, valid_to, is_current, change_reason)
VALUES (4821, 'Starter', TIMESTAMP '2026-11-27 09:00:00', NULL, TRUE, 'correction');
COMMIT;The common failure mode is a straight UPDATE of the plan column, which destroys the audit trail. The rubric rewards closing the old row's validity window and inserting a new row (the pattern often called slowly changing dimension type 2), or writing an explicit retraction record, so anyone can reconstruct what the business believed and when. You do not need years of production experience to answer this well; you need to explain why history matters to finance, audit and every report built on top.
What do interviewers look for when you solve a SQL question live?
Live SQL rounds are scored against a rubric, not a single correct answer. Most interviewers for data engineering roles run four checks.
| What they check | What a strong candidate does |
|---|---|
| Clarifying questions | Asks about the grain of the table, what counts as a duplicate and how late rows should be treated, in the first two minutes |
| Stated assumptions | Says assumptions out loud (nulls, ties, time zones) so the interviewer can correct them cheaply |
| Trade-offs | Explains why a window function rather than GROUP BY, why an incremental filter rather than a full reload |
| A working query | Ends with a query that runs, then mentions how it behaves at scale (partition pruning, indexes) |
Failure modes that cost points without you noticing
Silent losses come from skipping the clarification step, coding in silence for ten minutes and never mentioning cost or performance. A correct query delivered without explanation often scores lower than a slightly imperfect one with clear reasoning.
How do you structure a 4-week SQL practice plan before a data engineer interview?
Treat the four weeks as two blocks: two weeks on query mechanics, two weeks on pipeline logic and live performance. Score yourself after every question against the rubric (correctness, then readability, then edge cases), not against an answer key.
| Week | Focus | What to do |
|---|---|---|
| Week 1 | Window functions | ROW_NUMBER for dedup, LAG for row-over-row changes, running totals with explicit frames. Four or five questions per session, with the failure mode you hit written next to each one. |
| Week 2 | Late-arriving data | Pair every window question with a late-data variant: re-rank after a duplicate arrives, restate a total when a correction lands. |
| Week 3 | Pipeline logic | Watermarks, MERGE-based upserts, partition-scoped backfills, and tracing a wrong metric back to a bad join. |
| Week 4 | Live mock sessions | One question a day, solved out loud in 25 minutes, scored on the four-point rubric. If you cannot explain your dedup choice, you are not done. |
Which SQL mistakes get data engineer candidates rejected fastest?
- Window functions without partition logic. A ROW_NUMBER without the right PARTITION BY silently keeps the wrong row.
- Full-table rewrites where incremental logic belongs. Recomputing everything signals you have never paid for a pipeline's compute.
- Ignoring late-arriving data. Not asking "what if this event arrives tomorrow?" ends pipeline interviews quickly.
- No rubric awareness during the live round. Interviewers score correctness, then readability, then edge cases.
- Reporting answers to pipeline questions. When asked to debug a dedup step, talk about the pipeline, not the chart.
How can DataSAI help you prepare?
DataSAI is a data science, AI and cloud computing consulting company, and its academy trains people for data roles in English and French. The Data Engineering Bootcamp covers SQL, Python, ETL, Spark, Airflow and the cloud over 14 weeks, with window functions taught as pipeline logic and an evaluation rubric for each exercise. The next cohort is being planned: you can join the waiting list with no payment.
If your SQL foundations need work first, the Data Analyst Bootcamp starts on January 4, 2027, with launch pricing until December 18. For a scored mock interview with an expert, our one-on-one mentoring starts at $165 per session (€149 in Europe). All prices are on the pricing page.
Conclusion
Data engineer SQL interviews reward one thing above all: showing that you can move data without breaking it. Practice window functions until partitioning and tiebreakers are reflexes, then move to watermarks, idempotent merges, scoped backfills and late-arriving data. Score every attempt against the rubric an interviewer uses, and practice talking while you write. Fifty questions done that way will prepare you better than two hundred checked against an answer key.
FAQ
Are SQL interview questions for data engineers different from data analyst questions?
Yes. Analyst questions focus on joins, aggregations and reporting queries. Data engineer questions add window functions for deduplication, incremental loads with watermarks, late-arriving data and debugging queries that broke in production. Practicing only reporting queries prepares you for about half of the interview.
How many SQL practice questions should I solve before a data engineer interview?
There is no fixed number, but a four-week plan at four or five questions per session works out to roughly 50 to 60 questions. Quality matters more than volume: score each attempt against a rubric covering correctness, readability and edge cases, and write down the mistake you made.
Can I use ChatGPT to practice SQL interview questions?
Yes, with limits. It can generate pipeline-style prompts and critique your queries, which helps with volume. It cannot reproduce a live interviewer who expects clarifying questions, stated assumptions and trade-offs explained out loud. Use it for drills, then do scored mock sessions with a person.
Do data engineer interviews use a specific SQL dialect like PostgreSQL or Snowflake?
Usually not strictly. Most interviewers accept standard SQL and care about your logic. Knowing dialect differences still helps, for example QUALIFY in Snowflake and BigQuery or MERGE behavior with duplicate source rows. If the job posting names a warehouse, read its documentation for upserts and window functions.
What SQL level is expected for a junior data engineer?
Juniors are expected to write solid window functions (ROW_NUMBER, LAG, running totals), deduplicate deterministically and reason about incremental loads and idempotency, even without production experience. Explaining why your query keeps the right row matters more than memorized syntax.
Sources accessed November 27, 2026: Stack Overflow, 2026 Developer Survey results (October 6, 2026), PostgreSQL documentation, window functions, PostgreSQL documentation, window function calls and frames, Snowflake documentation, MERGE, Google BigQuery documentation, QUALIFY clause. The rubrics and the practice plan reflect common interview practice and DataSAI's teaching approach.
Thinking about a move into data? Read our honest guide to switching to a data career and what a realistic plan looks like at 40. Want to learn pipelines with a structured program? Join the waiting list for the Data Engineering Bootcamp. All prices are on the pricing page.
Want to practice SQL on a real schema? Our 25 Oracle SQL practice questions with answers give the expected result of every query, from SELECT to CONNECT BY.