Data Engineer
SQL questions
54 questions on SQL for data engineers, easiest first.
Easy 11
- Purpose of a primary keyeasy
- Row count of a LEFT JOINeasy
- Filtering with = NULLeasy
- COUNT(*) vs COUNT(column)easy
- Filtering groups with HAVINGeasy
- Adding a number to NULLeasy
- Orders pointing to missing customerseasy
- First check after a migrationeasy
- Removing duplicate order idseasy
- Grouping sales by montheasy
- avg and count with a null valueeasy
Medium 24
- Joining with a small lookup tablemedium
- Upserting into a target tablemedium
- Keeping the latest row per keymedium
- RANK and DENSE_RANK with tiesmedium
- NOT IN with a NULL in the listmedium
- Day-over-day change with LAGmedium
- WHERE filter after a LEFT JOINmedium
- Counting orders for every customermedium
- Table state after a MERGEmedium
- Revenue doubled after a joinmedium
- Employees above their team averagemedium
- Keeping SQL in separate filesmedium
- Selecting current rows from SCD2medium
- Joining facts to the right SCD2 versionmedium
- Keeping one row per ordermedium
- Row counts match but money does notmedium
- Keeping the latest row per customermedium
- Applying a batch of changesmedium
- Joining two topics in Kafka Streamsmedium
- Joining with a small reference tablemedium
- Matching orders with paymentsmedium
- Subtotals with rollupmedium
- Same timestamp, different hourmedium
- Rows missing after a != filtermedium
Hard 19
- Running total with tied dateshard
- LAST_VALUE returns the current rowhard
- Longest login streakhard
- FULL OUTER JOIN row counthard
- GROUP BY with NULL keyshard
- Recursive CTE stopping pointhard
- Double counting in an SCD2 joinhard
- Distinct users on billions of rowshard
- Which day does an event belong tohard
- Date key for a late-night Dubai orderhard
- MERGE fails on duplicate source rowshard
- Revenue inflated by repeated eventshard
- GST totals off by a few rupeeshard
- No FX rate for Saturday ordershard
- Bank and app never agree on a dayhard
- Duplicates that slip past a stream dedupehard
- Revenue tripled after a joinhard
- Monthly users from daily usershard
- Enriching events with a changing tablehard