dim_customer is the target table and stg_customer is today's staged batch; both have columns customer_id, email, city, updated_at. The nightly MERGE follows these rules:
- •The batch can hold several rows for one customer; only the one with the latest
updated_at is applied. - •A staged row replaces the target row only when its
updated_at is later than the target's. Otherwise the target row is kept as it is. - •A customer the target doesn't have is inserted.
- •Target rows the batch doesn't mention are left alone.
Without running a MERGE, return dim_customer as it will look afterwards: one row per customer.
Columns: customer_id, email, city, updated_at. Sort by customer_id.