The promotions team wants to know how many orders really used an active promotion. An order used a valid promotion when its promo_id exists in promotions and the order_date falls between that promotion's start_date and end_date, both inclusive. Orders without a promo_id, with an unknown promo_id, or with a promotion that was not running that day do not count, but every order is part of the total. Write an SQL query that returns a single column, valid_promo_pct, rounded to 2 decimal places.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.