SQL data engineering interview problem. Difficulty: beginner. Pattern: Deduplication. About 20 minutes. Free to practice.
You inherited a broken silver job. Airflow marked silver_events green; dbt's unique test on event_id is red. QA pasted duplicate replay rows in the incident log. The editor starts from the buggy SQL that shipped Friday. Fix it so: one row per event_id (latest ingest_time wins) columns: event_id, user_id, session_id, event_type, product_id, device, country, event_time ordered by event_id idempotent: running the job twice must not change the grain That collapses the whole table to one row.
Input: -- the shipped query has no PARTITION BY: QUALIFY ROW_NUMBER() OVER (ORDER BY ingest_time DESC) = 1 -- ecommerce_events has 812 rows total Output: event_id | user_id | event_type | event_time E00617 | U031 | page_view | 2026-08-19 06:39:09 Why this passes: Each user's eligible order totals are aggregated; users with higher totals appear earlier in the ranked output.
Topics: debugging, dedup, idempotency.
More SQL interview questions · All interview problems · Learn data engineering
Production ticket: On-call: dbt unique_silver_events_event_id failed after a 'successful' DAG run.
You inherited a broken silver job. Airflow marked `silver_events` green; dbt's unique test on `event_id` is red. QA pasted duplicate replay rows in the incident log. The editor starts from the **buggy SQL that shipped Friday**. Fix it so: - one row per event_id (latest ingest_time wins) - columns: event_id, user_id, session_id, event_type, product_id, device, country, event_time - ordered by event_id - **idempotent**: running the job twice must not change the grain Do not filter to a single global ROW_NUMBER. That collapses the whole table to one row.