Alexander_89

BB_1

Jun 21st, 2023
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.43 KB | None | 0 0
  1. /*create table oper (date date, cnt int)
  2. insert into oper values
  3. ('2019-06-02',     1985),
  4. ('2019-06-03',     1577),
  5. ('2019-06-04',     1597),
  6. ('2019-06-05',     1468),
  7. ('2019-07-06',     82),
  8. ('2019-07-08',     1689),
  9. ('2019-07-09',     1556),
  10. ('2019-07-10',     1480),
  11. ('2019-07-11',     1405),
  12. ('2019-07-12',     1502)*/
  13. SELECT date, SUM(cnt) OVER(PARTITION BY DATE_TRUNC('month', date) ORDER BY date)
  14. FROM oper
Advertisement
Add Comment
Please, Sign In to add comment