
use mytools;
DROP TABLE IF EXISTS invoices;
CREATE TABLE invoices (id INTEGER, amount INTEGER, the_date date);

INSERT INTO invoices VALUES (1000,1000,'2021-10-01');
INSERT INTO invoices VALUES (1000,300, '2022-11-03');
INSERT INTO invoices VALUES (1000,400, '2022-12-07');

INSERT INTO invoices VALUES (2000,2500,'2021-01-08');
INSERT INTO invoices VALUES (3000,3600,'2022-02-09');
INSERT INTO invoices VALUES (4000,4700,'2022-03-10');

SELECT  id, SUM(amount) AS total_amount
FROM invoices
GROUP BY id WITH ROLLUP

