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 DISTINCT
DATE(s.time_stamp) time_stamp,
FIRST_VALUE(SUM(s.sales_quantity)) OVER (PARTITION BY DATE(s.time_stamp) ORDER BY s.time_stamp DESC) sales_quantity
FROM sales s
GROUP BY s.time_stamp;
time_stamp | sales_quantity |
---|---|
2020-01-14 | 1100 |
2020-01-15 | 1240 |