Practice · medium · dataset: ecom

Refund share by category

For each product category, compute the percentage of line-item revenue that came from refunded orders. Revenue is quantity times the line’s unit_price.

Return category and refund_share_pct rounded to two decimals. Sort by refund_share_pct descending, then by category ascending.

Tables available

Table Columns
orders order_id, customer_id, order_date, status, channel
order_items order_id, product_id, quantity, unit_price
products product_id, name, category, unit_price

The percentage is refunded revenue divided by total revenue for that category, times 100. Only orders whose status is refunded count toward the numerator.

⌘/Ctrl + Enter to grade

Write a query, then grade it.

Hints

Try it first. Reveal a hint only when you are stuck.