CODE WORKSPACE

Dedupe staging before merge

Keep one deterministic staged row per customer key before a target merge.

The SQL API will hydrate this workspace with the exercise-specific starter query and schema.

Sample input

customer_stageCustomer 104 has two staged rows. Keep the latest updated_at, using batch_id as a tie-breaker.
customer_idemailtieris_deletedupdated_atbatch_id
101ana@example.comgold02026-03-05 10:00:007001
102ben@example.comsilver02026-03-05 11:00:007001
103cy@example.combronze12026-03-05 12:00:007001
104dee-old@example.comgold02026-03-05 09:00:007000
104dee@example.complatinum02026-03-05 12:30:007001
105eli@example.combronze02026-03-05 08:00:007001
nullghost@example.comsilver02026-03-05 13:00:007001
106fay@example.comsilver02026-03-04 23:30:006999

Expected output

Expected outputThe NULL key is excluded and only the latest row for customer 104 survives.
customer_idemailtieris_deletedupdated_atbatch_id
101ana@example.comgold02026-03-05 10:00:007001
102ben@example.comsilver02026-03-05 11:00:007001
103cy@example.combronze12026-03-05 12:00:007001
104dee@example.complatinum02026-03-05 12:30:007001
105eli@example.combronze02026-03-05 08:00:007001
106fay@example.comsilver02026-03-04 23:30:006999

Constraints

Load the live SQL exercise to inspect the full prompt, schema, starter query, and expected output.

Expected skills

ROW_NUMBER, Dedupe, Staging

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.