RANK ≤ 4 by units in a category: paid, Sep–Nov 2025
Instructions
The units sold of a product are the sum of quantity over the items of orders with the status 'paid' created on or after September 1, 2025 and strictly before December 1, 2025; products without sales in this period are not considered. Within each category, rank the products by sales descending using RANK(): products with an equal number of units get the same place, and the next place is skipped. Output the products that took places 1 to 4 inclusive (place <= 4); because of ties in sales there may be more than 4 such products in a category. Columns: category (the category name), product (the product name), units, place. Row order does not matter.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Table relationships
- N:1Many-to-one
order_items.→order_id orders.id - N:1Many-to-one
order_items.→product_id products.id - N:1Many-to-one
orders.→customer_id customers.id - N:1Many-to-one
products.→category_id categories.id
Table data
Select a table in the diagram or list to view its rows.