You're an analyst at TinkerCart, an online marketplace. The frontend stores each order as a single JSONB document in the details column, containing the sales channel, applied coupon, and total amount. The marketing team needs a flat dataset showing which channels orders come from and which coupons are actually used, so they can decide which promotional campaigns to extend.
Extract the JSON values into regular columns. Some orders have no coupon at all. Include those orders too, with no coupon value.
Return these columns:
- order_id — order ID (integer);
- channel — value of the channel key, as text;
- coupon — value of the coupon key, as text; NULL if no coupon is present;
- total_amount — value of the total key, cast to numeric without rounding (keep the stored value exactly).
Sort by order_id in ascending order. Return exactly one row per order, without filtering out any orders.
order_idchannelcoupontotal_amountShowing the first 3 rows of the sample — the full sample comes with Premium
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in