views:

4

answers:

0

Hi,

I have the following dataset (simplified):

GroupA,GroupB,GroupB Weight,GroupC,X,Y

a1,b1,c1,0.4,3,9

a1,b1,c1,0.4,5,7

a1,b2,c2,0.6,6,8

In the report I display the ratios - X/Y even for the groups - Sum(x)/Sum(y). But for the final group (A) I need to weight groups B differently according to the weight listed. I thought about something like: Sum(BWeight*Sum(x, GroupBScope)/Sum(y, GroupBScope)) but I'm on SQL2008 R1 so I can't use aggregate of aggregates.

Does anyone see a way to do this with the builtin functions? If not, can I do it with custom code (or assembly) and how?

Thanks