Skip to main content
All Questions

E-commerce (3 of 5)

Medium
Unlock detailed company stats for this questionUpgrade

Amazon is a large e-commerce platform where customers can order various items ranging from electronics to clothing.

You're provided with two tables, orders and items, with the following columns:

order_idcustomer_idorder_dateitem_idorder_quantity
integerintegerdateintegerinteger
item_iditem_category
integerstring

Write an SQL query to find how many units were ordered in each category in the last 7 days, for each day of the week. Sort alphabetically by item_category.

Desired output example:

item_categoryorder_datetotal_units_ordered
Books2023-09-264
Books2023-09-285
Clothing2023-09-277
Clothing2023-09-303
Electronics2023-09-252