October 30, 2006 at 3:31 pm
Having trouble working out the return of an index, where the return is the sum of the contributions (a*b/sum(b)). a is the return. b is the market cap. b/sum(b) is the weight of each stock.
October 30, 2006 at 3:42 pm
Can u post ur SQL?
October 30, 2006 at 3:59 pm
What do your tables look like? And it would help to see some sample data and the result(s) you want from that data.
-SQLBill
October 30, 2006 at 5:40 pm
Easier than I thought;
select sum(A * B)/ SUM(B)
Works a treat.
November 1, 2006 at 1:33 am
select sum(a*b) / (select sum(b) from...where....) from... where
I like the complicated version of things....
Probably you'd want the from...where to be the same in both statements, but it has worked for me this way few times to have my way with things.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply