Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE INTERNET (
- PUR_DATE DATE,
- IM VARCHAR(100),
- SKD INT,
- PRICE INT
- );
- INSERT INTO INTERNET (PUR_DATE, IM, SKD, PRICE)
- VALUES
- ('2021-02-02', 'ZOOSHOP', 1, 5000),
- ('2021-02-04', 'ZOOSHOP', 1, 5000),
- ('2021-02-05', 'ZOOSHOP', 2, 3700),
- ('2021-02-08', 'ZOOSHOP', 2, 3700),
- ('2021-02-09', 'ZOOSHOP', 3, 1800),
- ('2021-02-13', 'PROMARKET', 1, 5000),
- ('2021-02-14', 'PROMARKET', 4, 2200);
- SELECT (SELECT SUM(PRICE)
- FROM INTERNET
- WHERE PUR_DATE <= T1.PUR_DATE) COSTS
- FROM INTERNET T1
- ORDER BY IM, PUR_DATE
- OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement