Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
Return customer_id and load_action after deduping customer_stage and comparing to dim_customer_current.
Result columns · in this order
customer_idload_actionHow to approach it
Rank customer_stage, keep clean_stage, left join to current target, then label actions.
Sample input
| customer_id | stage_tier | target_tier | is_deleted |
|---|---|---|---|
| 101 | gold | silver | 0 |
| 103 | bronze | bronze | 1 |
| 104 | platinum | gold | 0 |
| 105 | bronze | bronze | 0 |
4 rows — all rows shown.
Expected output
| customer_id | load_action |
|---|---|
| 101 | update |
| 102 | insert |
| 103 | delete |
| 104 | update |
| 105 | unchanged |
| 106 | insert |
6 rows — all rows shown.
Constraints
Ignore NULL customer_id rows. Keep the latest staged row per key by updated_at DESC, batch_id DESC. Use labels insert, update, delete, unchanged. Order by customer_id.
Expected skills
Source-target comparison, deterministic staging dedupe, and load-action CASE logic.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.