D8LoopWrite a query that traces returning-user retention by signup cohort and active week.
Open the supported preview exercise with schema context, draft saving, run previews, and structured submit feedback.
Write a query that traces returning-user retention by signup cohort and active week.
Identify duplicates, negative revenue rows, and broken order-state transitions.
Rebuild a multi-stage revenue view while preserving clear intermediate logic.
Inspect paid orders by selecting explicit columns, filtering, and ordering the newest first.
From item-grain rows, count item rows, distinct orders, and distinct products.
Combine a status set, a half-open date range, and an amount threshold with correct precedence.
Label missing countries as 'unknown' and keep only active customers.
Bucket orders into value bands with CASE and return a deterministic ordering.
Group orders by status to sanity-check the table the way an engineer would.
Join shipped orders to their buyer to attach the buyer's country.
Use a LEFT JOIN and an IS NULL test to find customers with no orders.
Join orders to order_items and count the line items for each order that has any.
Total order revenue grouped by buyer country, labelling a missing country as 'unknown'.
Use a LEFT JOIN and IS NULL to find orders that have no rows in order_items.
Use EXISTS to return customers who have at least one shipped order, without duplicates.
Use named CTE layers to filter paid or shipped orders and aggregate buyer revenue.
Use a scalar subquery to return orders above the overall average amount.
Use a correlated EXISTS subquery to return customers with shipped order activity.
Aggregate buyer revenue in a derived table, then filter the outer query.
Normalize order status buckets once, then count orders by the cleaned status.
Compose a readable multi-CTE country revenue query with clear intermediate names.
Keep the newest snapshot per order_id using ROW_NUMBER.
Rank buyers by total revenue and return the leading buyers.
Use LAG to calculate day gaps between each buyer order and the previous order.
Return daily revenue with cumulative running revenue over time.
Return first and latest order timestamps for each buyer.
Create a compact retention slice by cohort day and activity day offset.
Count events by the day they happened, not the day they arrived.
Assign each user event a stable sequence number using event and ingestion time.
Bucket UTC events into a Pacific-style reporting day using a fixed offset.
Extract device and campaign fields from JSON event payloads.
Expand checkout item arrays into one row per event-item pair.
Count late-arriving events by the original event day.
Compare staged customer rows to the current dimension and classify insert, update, unchanged, and delete candidates.
Keep one deterministic staged row per customer key before a target merge.
Return only staged rows that should affect the target, excluding unchanged records.
Find null and duplicate unique keys that would make an upsert unsafe.
Detect changed dimension rows and compute close/open validity boundaries.
Compare current snapshot rows against incoming source state and classify drift.
Identify event partitions that need replay because late or corrected records arrived.
Produce insert, update, delete, and unchanged counts for a load audit report.
Summarise order count and revenue per status with GROUP BY.
Average order amount per buyer country, labelling a missing country as 'unknown'.
Return buyers whose total revenue is at least 500 using HAVING.
Count the number of different buyers per status.
Per buyer, return paid revenue and refunded amount in one row using conditional aggregation.
Per country, the share of orders that are paid, using decimal-safe division.
Find every order_id stored more than once in order_snapshots, with its count.
Report total customers, the count missing a country, and the missing rate.
Report orders without line items and orphan line items as two counted checks.
Surface orders whose stored total disagrees with the sum of their line items.
Flag orders whose total is more than twice the average order value.
Union four named checks into one pass/fail audit evidence table.
Produce an interview-ready country revenue output with exact columns, ordering, and an unknown bucket.
Join orders to item totals without multiplying order-level revenue.
Keep the latest order snapshot per order with deterministic window logic.
Rank buyers by paid revenue and include tied ranks with stable ordering.
Build a compact cohort retention slice from first order day and later activity days.
Find users whose checkout happened after a view using event-time ordering.
Extract JSON attributes and expand checkout item arrays into item-grain rows.
Classify deduped staged customer rows as insert, update, delete, or unchanged.
Detect current SCD2 rows whose staged attributes require a close/open history change.
Identify event partitions that need replay because of late or corrected records.
Flag expensive, wide, and full-scan query runs from warehouse metadata.
Union multiple named quality checks into one interview-ready audit evidence table.
Show partitions and MB scanned for a date range against the table totals.
Rank the query history by bytes scanned and return the three most expensive.
Find queries that scanned every partition of the table (no pruning).
Sum bytes scanned per analyst and convert it to an estimated dollar cost.
Flag each partition as hot or normal versus the average row count.
Rank queries by bytes scanned per partition to expose wide SELECT-* scans.