Interview Prep11 min read

Data Engineer SQL Joins Interview: The Query That Doubles Revenue

A mid-level Data Engineer SQL joins interview, simulated turn by turn: four illustrative mistakes on dedup, fan-out and EXCEPT, plus the 30-minute blueprint.

IT
InterviewStack TeamEngineering
|

Your query runs, the numbers look plausible, and the interviewer asks one quiet question: why is revenue higher than finance's total? In a mid-level Data Engineer SQL joins interview, correct syntax is the easy part. The points go to the candidate who defends the grain of the result before anyone has to find the bug.

This is a simulated mock interview built on one AI interview blueprint, with illustrative mistakes and coaching. It is not a transcript of a real person or a real company's questions.

Key Findings

  • The interview is scored out of 100 points across 4 dimensions; Technical Proficiency is only 20 of them.
  • Interviewer Objectives Alignment and Level-Specific Expectations are worth 30 points each, 60 of 100 combined.
  • The conversation runs 30 minutes in 3 phases: framing (minutes 0 to 6), core query design (6 to 20) and validation (20 to 30).
  • Core query design gets the longest slot at 14 minutes, and its checklist has 6 items.
  • The scenario joins 5 tables, and 2 of them (shipments and order items) are one-to-many against orders.
  • The validation phase gets 10 minutes, a third of the interview, and 5 checklist items.
  • The interviewer has 6 prepared follow-ups; this walkthrough dramatizes 4 of them.

The Overlap Hides in the Setup

Two order systems are live during a migration, so the same order can sit in both. Before any join, the question is already a trap.

The interview question

You are supporting a commerce analytics team that wants a daily dataset of fulfilled orders for a marketplace with two order systems during an ongoing migration. The same real-world order may appear in both order tables. Some orders never ship, and some have multiple shipments. Some customer records are missing. Analytics defines a fulfilled order as one with at least one non-null delivered_ts.

legacy_orders (order_id, customer_id, order_ts, status, country_code, total_amount)
new_orders    (order_id, customer_id, order_ts, status, country_code, total_amount)
shipments     (shipment_id, order_id, shipped_ts, delivered_ts, carrier)
order_items   (order_id, sku_id, quantity, item_price)
customers     (customer_id, signup_date, segment)

Using the tables above, how would you build a SQL query for a daily dataset of fulfilled orders for the last 30 days, with one row per order and enough fields to report order date, delivered date, customer segment, country, item count, and order revenue?

The interviewer is probing whether you can translate a business request into correct SQL, pick join types and set operators on purpose, avoid duplicate counting, and validate with edge cases such as missing dimensions and conflicting data across systems. A mid-level bar means a mostly correct end-to-end shape with stated assumptions, even if the syntax is imperfect.

Four Follow-Ups, Four Places Points Leak

Each turn below shows a common answer, then the stronger move. Marcus is a composite candidate used only for illustration.

Turn 1: Two systems, one order

Interviewer: "If the same order can exist in both order systems, how would you combine those sources without double-counting orders?"

COMMON MISTAKE
Marcus just UNIONs the two tables and moves on, never asking whether the overlapping copies are identical. That misses the expected check that overlapping order sources need an explicit dedup approach, and it costs points under Interviewer Objectives Alignment (30 points).
STRONGER MOVE
Name the key (order_id), then stack both sources with UNION ALL and dedupe on that key with a stated rule for which system wins when the copies disagree. Say out loud why plain UNION is not enough: it only drops rows that match in every column.

Turn 2: Shipments multiply rows

Interviewer: "Shipments is one-to-many with orders. How would you prevent row multiplication while still deriving a delivered date?"

COMMON MISTAKE
Marcus joins shipments straight onto orders and then reaches for DISTINCT to clean up the extra rows. Revenue is already inflated by then, and the one-to-many risk the blueprint wants flagged in the framing phase never gets named, which costs points under Interviewer Objectives Alignment (30 points), since avoiding row multiplication is a stated interviewer objective.
STRONGER MOVE
Collapse shipments to one row per order in a subquery first, then join that result. Use MIN or MAX of delivered_ts, say which one you chose, and note that fulfilled means at least one non-null delivered_ts. Do the same for order_items before you count items.

Turn 3: Audit the migration

Interviewer: "Suppose finance wants to identify orders present in legacy_orders but not in new_orders during the migration window. How would you approach that with a set operation?"

COMMON MISTAKE
Marcus proposes a LEFT JOIN with a null check for orders in legacy but not in new, and cannot say when a set operation is the cleaner tool. That leaves out the checklist item about a concrete use of EXCEPT or INTERSECT for migration auditing, and weakens the Level-Specific Expectations score (30 points).
STRONGER MOVE
Select just order_id from each side and use EXCEPT for legacy-only orders. Pair it with INTERSECT to size the overlap, and mention that both compare whole rows, so the column list must be deliberate.

Turn 4: Prove it is right

Interviewer: "How would you validate that your final query really returns one row per fulfilled order and not inflated revenue or item counts?"

COMMON MISTAKE
Marcus runs the query, eyeballs a few rows and says it looks right. There is no duplicate check and no before-and-after count, so the validation checklist items are missed and it costs points under Level-Specific Expectations (30 points), which include practical validation habits for a 2-5 year Data Engineer.
STRONGER MOVE
Check that the row count equals the distinct order_id count, then reconcile order counts before and after each join to catch fan-out. Finish by tying revenue and item totals back to the source tables.

Why Isn't Spotting These Mistakes Enough?

You probably saw every one of those coming. That is the trap: on the page you have unlimited time and one question at a time. Live, you have a few seconds, a half-written query, and an interviewer who changes direction mid-sentence. Reading about fan-out does not train you to say "let me check the grain" before you type the join.

The skill is retrieval under pressure, and it only comes from reps. A live mock interview gives you the follow-ups you cannot predict and scores you against the rubric, so the gaps show up before the real one does.

What Does a Strong Data Engineer SQL Joins Interview Look Like?

This is the blueprint a strong candidate hits, and it is exactly what the AI mock interview tracks you against in real time. The three phases split the 30 minutes into 6, 14 and 10.

The 30-minute interview paced into three phases

Blueprinta strong 30-minute interview, phase by phase
1
Problem framing and data modeling 0-6
  • ✓States target grain explicitly as one row per fulfilled order
  • ✓Recognizes two order sources may overlap and require deduplication
  • ✓Recognizes shipments and order_items are one-to-many relative to orders
  • ✓Notes missing customer rows should not necessarily exclude valid fulfilled orders
2
Core query design 6-20
  • ✓Combines legacy_orders and new_orders in a way that addresses overlap, such as UNION ALL followed by deduplication or UNION when justified
  • ✓Filters to last 30 days using order date or clearly states an assumption if using delivered date
  • ✓Builds a shipment-level aggregation to get one delivered date per order and uses it to define fulfilled orders
  • ✓Builds an order_items aggregation to compute item count and optionally revenue if not trusting header totals
  • ✓Uses LEFT JOIN to customers so missing customer dimension records do not drop fulfilled orders
  • ✓Produces a final result with one row per order and the requested fields
3
Correctness, trade-offs, and validation 20-30
  • ✓Explains how to check for duplicate order_id in the final output
  • ✓Describes how to reconcile order counts before and after joins to detect fan-out
  • ✓Can articulate a concrete use of EXCEPT or INTERSECT for migration auditing or consistency checks
  • ✓Discusses implications of UNION vs UNION ALL on correctness and performance
  • ✓Calls out assumptions around delivered date selection when multiple deliveries exist

Interviewer scoring weights across four rubric dimensions

Notice how much of the card is judgment, not syntax: stating the grain, naming assumptions, and checking your own output. Those are the 60 points under Interviewer Objectives Alignment and Level-Specific Expectations.

Run This Join Scenario Live

Take this exact scenario into a timed session. Start the AI mock interview for a mid-level Data Engineer on SQL joins and set operations and answer the same opening question, then see how you handle follow-ups you have not read yet. It tracks you against the blueprint above while you talk.

Want a warmer-up first? Drill single questions in the joins and set operations question bank, or browse the Data Engineer preparation guides for the wider topic map.

FAQ

Q. What does a Data Engineer SQL joins interview test?

It tests whether you can turn a business request into a query with a clear grain, then protect that grain. In our 30-minute blueprint, the big risks are double-counted orders across two source systems, row multiplication from one-to-many tables, and dropped rows from the wrong join type. Technical Proficiency is only 20 of 100 points; Interviewer Objectives Alignment and Level-Specific Expectations are worth 30 each.

Q. When should I use UNION versus UNION ALL?

UNION ALL keeps every row and skips the sort or hash step that removes duplicates, so it is cheaper. UNION removes exact duplicate rows, which only works if the duplicated rows are identical in every column. When the same order can differ between systems (a status, a timestamp), dedupe explicitly on order_id with a stated rule for which copy wins.

Q. How do I avoid row multiplication when joining shipments to orders?

Aggregate the many side first, to one row per order, then join that result. For a delivered date, a common choice is MIN or MAX of delivered_ts per order_id, and you should say which one you chose and why. The blueprint checks that you call out this assumption when multiple deliveries exist.

Q. Should the customers join be INNER or LEFT?

LEFT, when the goal is every fulfilled order. The scenario notes that some customer records are missing, and an INNER JOIN would silently drop valid orders. The blueprint lists this as an explicit check in the core query design phase.

Q. How do EXCEPT and INTERSECT help during a migration?

EXCEPT finds order_ids present in the legacy system but missing from the new one, which is the core of a migration audit. INTERSECT shows the overlap, which tells you how many orders are at risk of double-counting. Both compare whole rows, so select just the key (or a deliberate column list) first.

Q. How do I prove my query returns one row per order?

Compare the row count to a count of distinct order_id in the output, and reconcile order counts before and after each join to catch fan-out. Then compare revenue and item totals against the source tables. The blueprint spends its final 10 minutes (minutes 20 to 30) on exactly this kind of validation.

Q. How do I practice this kind of interview?

Run it live. The AI mock interview for this role, level and topic asks unscripted follow-ups and tracks you against the same three-phase blueprint in real time. The question bank is a good warm-up for individual join and set-operation questions first.

Your Next Rep Is the Grain

Before the next join you write, say the grain of the result out loud and check it again at the end. That one habit covers most of what this interview rewards.

Topics

Data EngineerSQL joinsset operationsUNION vs UNION ALLrow fan-outmock interviewmid-level

Ready to practice?

Put what you've learned into practice with AI mock interviews and structured preparation guides.