I'm running an old co-workers query and ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW is used in the query. I'm curious as to when to just use UNBOUNDED PRECEDING by itself or like is written as above
I tried both methods and I get the same result but I only tried it on a subset of the data. I'm worried I could be missing something if I update the code, so i wanted to get a clear understanding of the concepts
E.g
SELECT *
, sum(pct) OVER(
PARTITION BY id, id2, zip
ORDER BY amount desc
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS cumulative_pct
FROM #a
vs.
SELECT *
, sum(pct) OVER(
PARTITION BY id, id2, zip
ORDER BY amount desc ROWS UNBOUNDED PRECEDING
) AS cumulative_pct
FROM #a