E-commerce: Units Ordered Yesterday
EasyPremium
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:
Write a SQL query that determines how many units were ordered on Amazon yesterday. Output it under the total_units_ordered_yesterday
-- SQLite (used by code editor)
SELECT SUM(o.order_quantity) AS total_units_ordered_yesterday
FROM orders o
WHERE o.order_date = date('now', '-1 day');
-- MySQL
SELECT SUM(o.order_quantity) AS total_units_ordered_yesterday
FROM orders o
WHERE o.order_date = DATE_SUB(CURDATE(), INTERVAL 1 DAY);
select sum(order_quantity) as total_units_ordered_yesterday from orders as ord join items as it on ord.item_id=it.item_id where order_date="2023-10-14"