When we use an OVER()
clause to create a window function in SQL, we often use a PARTITION BY
clause to partition the results. This can be handy if we want to do stuff like calculate subtotals.
But we can also use an empty OVER
clause to calculate a grand total.
We might want to do this if we’re already using another OVER
clause to calculate subtotals, but we also want a column to provide the grand total.