I have two queries almost similar:
SELECT *
FROM table
QUALIFY SUM(1) OVER (PARTITION BY id_field ROWS UNBOUNDED PRECEDING) = 1;
and
SELECT *
FROM table
QUALIFY SUM(1) OVER (PARTITION BY id_field) = 1;
I cannot put my finger on why the ROWS UNBOUNDED PRECEDING
has any effect on the queries.
To me, it would seem like both queries would yield the same result, since the function SUM is not using any column of my table, and so ROWS UNBOUNDED PRECEDING would not influence the SUM.
But actually, the first query yields more rows as a result than the second one when I execute it.
What is the difference betwen both queries, and what is the effect of ROWS UNBOUNDED PRECEDING on this particular QUALIFY?
ROWS UNBOUNDED PRECEDING
withoutorder by
? – Vamsi Prabhala