Skip to content
Advertisement

Tag: window-functions

SQL: partition by / window function with the combination of 2 columns, separated by todays date

I am trying to create a materialized-view in postgres, where I sum 2 columns, depending on todays date within a window function. In the below picture there is an example of the query I am trying to achieve: If today is the ‘2022-06-06’: 2022-06-05: 1+2+3+4+5 2022-06-06: 1+2+3+4+5+6+107 2022-06-07: 1+2+3+4+5+6+107+108 Here is a sample fiddle with date: http://sqlfiddle.com/#!15/538ea7/1 Updated: http://sqlfiddle.com/#!15/bef30/3 Would

Advertisement