ShopSphere wants to identify its highest-revenue products from recent sales activity. Write a SQL query to find the top 5 products by revenue in the last 30 days, excluding any returned items.
Assume the query is run relative to the latest date in the dataset, and revenue should be calculated as quantity * unit_price.
Requirements
- Use only order items from the last 30 days based on
orders.order_date.
- Exclude items where
order_items.is_returned = true.
- Join the necessary tables to return product names.
- Aggregate revenue by product.
- Return the top 5 products ordered by revenue descending.