Is it possible to use the where clause inside overclause as shown below?
SELECT SUM(amount) OVER(partition by prod_name WHERE dateval > dateval_13week)
I canβt use the previous and next inside over, because my dates are out of order. All I need to get are records whose values ββare less than the 13-day date of the current record.
EDIT :
sum(CASE WHEN dateval >= dateval_13week and dateval <=current_row_dateval then amount else 0 end) over (partition by prod_name order by week_end desc)
To clarify, I used to break records with the following query, when I had all my dates in sequence. Now I have the dates in random order, and there are some missing dates.
sum(amount) over
(partition by prod_name order by prod_name,week_end desc rows between 0 preceding and 12 following)
source
share