Skip Navigation Links Home Blogs

cubido > Blogs > Posts > Building the Product over a grouped Set of Records
July 04
Building the Product over a grouped Set of Records
Building the SUM, MIN, or MAX .. of over a grouped set of Records this is very easy.

Invenstment | Year  | InterestPrevYear
--------------------------------------
Warehouse_1 | 2004  | 1,05
Warehouse_1 | 2005  | 1,2
Warehouse_1 | 2006  | 1,3


SELECT investment, SUM(InterestPrevYear)
FROM sales.revenue_year
GROUP BY investment

--> Warehouse_1 | 3,55

We want to build the product to charge the interest over the last 3 years, the SUM or any other kown aggregte function is not correct in this case.
We must build the product to charge the interest!

Remember: a*b*c = exp(Log(a*b*c )) = exp(log(a) + log(b) + log(c))

SELECT investment, EXP(SUM(LOG(PercRevenueYear)))
FROM sales.revenue_year
GROUP BY investment

--> Warehouse_1 | 1,638


THIS IS IT!!

Comments

There are no comments for this post.
 

 Add Comment

 
Titel  
Your Name:  
Your Comment:  
Your EMail:  
*