Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*create table oper (date date, cnt int)
- insert into oper values
- ('2019-06-02', 1985),
- ('2019-06-03', 1577),
- ('2019-06-04', 1597),
- ('2019-06-05', 1468),
- ('2019-07-06', 82),
- ('2019-07-08', 1689),
- ('2019-07-09', 1556),
- ('2019-07-10', 1480),
- ('2019-07-11', 1405),
- ('2019-07-12', 1502)*/
- SELECT date, SUM(cnt) OVER(PARTITION BY DATE_TRUNC('month', date) ORDER BY date)
- FROM oper
Advertisement
Add Comment
Please, Sign In to add comment