RienSQL
TASK #158 · Medium · Zalando

Inventory State Breakdown

Your brief
The inventory table stores the current status of every physical unit: Sold, Available, or Returned.

Write a query that for every product in products returns product_name and three counters: units_sold, units_available, units_returned. Products that have no inventory units yet must also appear in the output with zeros in the corresponding columns.
Expected columnsproduct_name units_sold units_available units_returnedZalando
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
productsproduct_id, product_name, category, price
reviewsreview_id, product_id, user_id, submit_date, stars
inventoryinventory_id, product_id, status, add_date
ordersorder_id, user_id, order_date
order_itemsitem_id, order_id, product_id, quantity