'Groceries': past cancellations, none in Jun 16–Jul 6, 2025
Level: Middle100 XP
Instructions
Find products in the category 'Groceries' (category_id = 8) that were in cancelled orders before, but not in the given period. "Was in a cancelled order" means: has an item in an order with the status 'cancelled'. The period: the order was created on or after June 16, 2025 and strictly before July 7, 2025; "before" means the order was created strictly before June 16, 2025. Output id, name, price and last_cancelled: the creation date of the latest such order before the period (created_at cast to date). 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
Exactly oneZero or oneZero or more
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
PostgreSQL
Select a table in the diagram or list to view its rows.