CODE WORKSPACE

SCD2 change boundaries

Detect changed dimension rows and compute close/open validity boundaries.

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

Sample input

dim_customer_history current rowsOnly is_current = 1 rows are candidates to close. Customer 101 is currently silver; 104 is currently gold.
customer_idtiervalid_fromvalid_tois_current
101silver2025-01-019999-12-311
104gold2026-02-209999-12-311
105bronze2025-12-019999-12-311
customer_stage changed rowsThe staged tier for 101 and 104 changed; 105 did not.
customer_idtierupdated_at
101gold2026-03-05 10:00:00
104platinum2026-03-05 12:30:00
105bronze2026-03-05 08:00:00

Expected output

Expected outputClose the old band on 2026-03-04 and open the new band on 2026-03-05 for changed customers.
customer_idold_tiernew_tierold_valid_fromold_valid_tonew_valid_fromnew_valid_to
101silvergold2025-01-012026-03-042026-03-059999-12-31
104goldplatinum2026-02-202026-03-042026-03-059999-12-31

Constraints

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

Expected skills

SCD2, History, Validity windows

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.