By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE sales (
id int auto_increment primary key,
time_stamp TIMESTAMP,
product VARCHAR(255),
sales_quantity INT
);
INSERT INTO sales
(time_stamp, product, sales_quantity)
VALUES
("2020-01-14 07:15:30", "Product_A", "100"),
("2020-01-14 07:15:30", "Product_B", "300"),
("2020-01-14 07:18:45", "Product_A", "200"),
("2020-01-14 07:18:45", "Product_B", "900"),
("2020-01-15 07:19:23", "Product_A", "400"),
("2020-01-15 07:19:23", "Product_B", "270"),
("2020-01-15 07:45:10", "Product_A", "900"),
("2020-01-15 07:45:10", "Product_B", "340");
SELECT
time_stamp,
SUM(sales_quantity) AS sales_quantity
FROM sales
GROUP BY 1;
time_stamp | sales_quantity |
---|---|
2020-01-14 07:15:30 | 400 |
2020-01-14 07:18:45 | 1100 |
2020-01-15 07:19:23 | 670 |
2020-01-15 07:45:10 | 1240 |