Are promo codes worth it?

MediumAmazonaggregationcoalescectescross joinconditional counts· 60 XP (20 per step)

Amazon's marketing team runs three promo codes: SPRING10, WELCOME5 and PRIME20. Finance asks: are the codes bringing in good orders, or just cheap ones that get sent back? Work through it in three steps. Leave cancelled orders out of every step.

Step 1: How much business do the codes bring?

For each promo code, plus orders with no code (labelled 'none'), show the number of orders and the total revenue (total_amount).

Expected output

  • One row per code plus one row for 'none'; any row order

Example of the shape (made-up values):

promo_code orders revenue
none 900 72000.00
SPRING10 120 9500.00

Hints, the later steps and the answer come with Pro.

Step 1 of 3

Write your query here. Ctrl + Enter submits.