I have found some SQL queries in an application I am examining like this:
SELECT DISTINCT
Company, Warehouse, Item,
SUM(quantity) OVER (PARTITION BY Company, War
Using sum()
as an analytic function with over partition by
is not necessary. I don't think there is a big difference between them in any sense. In oracle there are lot more analytic function than aggregation function. I think ms-sql is the same case. And for example lag()
, lead()
, rank()
, dense rank()
, etc are much harder to implement with only group by
.
Of course this argument is not really for defending the first version...
Maybe there were previously more computed fields in the result set which are not implementable with group by.