RANK: 3 rarest products, paid, May–Jun 2025
Instructions
A product's popularity is the number of orders with the status 'paid', created on or after May 1, 2025 and strictly before July 1, 2025, that contain it (orders_cnt); products without such orders are not considered. Within each category, rank the products by orders_cnt ascending using RANK(): products with equal orders_cnt get the same place, and the next place is skipped. Output the least popular products: those with place <= 3; because of ties there may be more than 3 of them in a category. Columns: category (the category name), product (the product name), orders_cnt, 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.