Business Intelligence Path · Mission 6 of 31Easy

Discount tiers need a reality check

Use CASE WHEN to bucket continuous values into categories and aggregate by bucket

Back to Business Intelligence

The Brief

Marcus WebbVP of Salessales-ops

Finance thinks we're leaving revenue on the table with our discount strategy — specifically, they suspect 'High' discount sales aren't pulling their weight. Bucket all sales (grain: one row per sale) into discount tiers — 'No Discount' for 0 or NULL, 'Low' up to 10%, 'Medium' 10–20%, 'High' over 20%. Give me the tier name, number of sales, and total revenue per tier, sorted by revenue descending. If 'High' discount drives less revenue than 'Medium' despite bigger giveaways, that's a conversation I want to have with finance before Monday.

You'll practice

CASE WHENNULL handlingBucketing

Tables & columns available

fact_salesfact8 columns
ColumnTypeKey
sale_idINTPK
employee_idINTFK → dim_employees
product_idINTFK → dim_products
region_idINTFK → dim_regions
sale_dateTEXT
quantityINT
revenueREAL
discountREAL

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Discounts have three real-world states — not given, given but tiny, given and material. Think about which of those NULL represents here and make sure it doesn't fall through to the wrong bucket.

Hint 2

Remember that NULL discount and 0 discount are different values but belong in the same business tier here

Hint 3

GROUP BY the CASE WHEN expression (or alias) to aggregate per tier