I have created a case statement for when a value is within a certain timeframe. For instance,

CASE

WHEN DATEDIFF(M, [DateA],[DateB]) <=3 THEN '<= 03 Mos.'

WHEN DATEDIFF(M, [DateA],[DateB]) <=6 THEN '<= 06 Mos.'

WHEN DATEDIFF(M, [DateA],[DateB]) <=9 THEN '<= 09 Mos.'

WHEN DATEDIFF(M, [DateA],[DateB]) <=12 THEN '<= 12 Mos.'

WHEN DATEDIFF(M, [DateA],[DateB]) <=24 THEN '<= 24 Mos.'

WHEN DATEDIFF(M, [DateA],[DateB]) <=36 THEN '<= 36 Mos.'

WHEN DATEDIFF(M, [DateA],[DateB]) <=48 THEN '<= 48 Mos.'

WHEN DATEDIFF(M, [DateA],[DateB]) <=60 THEN '<= 60 Mos.'

ELSE '> 60 Mos.'

For the values that are within each month segment, I want to be able to do a 'sum product' (as done in Excel) of ValuesC and ValuesD and divide it by the sum of the ValuesC. Therefore, these results for a certain month bucket should be the same. I've attached an example. I want to be able to automate the results shown in Column F.

Thank you.

Case---Sum-Product-Example.xlsx