Reputation: 31
How can I implement :
AVG(X) OVER(PARTITION BY SegmentId) AS AvgX
In a SQL query without using AVG(X)
?
I can only support sum, count, min, max, but not AVG
.
Thanks,
Or.
Upvotes: 1
Views: 119
Reputation: 367
This returns the same results, although the context is unclear..
SUM(X) OVER(PARTITION BY SegmentId) / COUNT(X) OVER(PARTITION BY SegmentId) AS AvgX
Upvotes: 1
Reputation: 1589
Conceptually, AVG(X)
can be replaced by SUM(X) / COUNT(X)
Is this answer an oversimplification of the problem at hand?
Upvotes: 1