Marketing Analytics Path · Mission 22 of 25Expert

Fix the product category mess

Use TRIM to fix trailing spaces and re-aggregate clean data

Back to Marketing Analytics

The Brief

Jordan LeeCEOexec-requests

Marcus showed me the product category breakdown and I'm seeing 'electronics' twice in the report. That can't be right. Can you figure out what's going on and give me a clean breakdown? I need the trimmed category, purchase count, and total revenue — sorted by revenue, no refunds.

You'll practice

TRIMData quality audit

Tables available

fact_purchases

Hints (3)

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

Hint 1

'electronics' appears twice because one has a trailing space. Use `TRIM(product_category)` to strip it

Hint 2

Use the trimmed value in both SELECT and GROUP BY: `TRIM(product_category) AS category ... GROUP BY TRIM(product_category)`

Hint 3

Filter `WHERE amount > 0` for purchases only, and use `ROUND(SUM(amount)::numeric, 2) AS total_revenue`. You should get 8 rows, not 9