Sorry, everyone, this is driving me nuts. I have the following query, which gives me the relative percentage of [INDEX MARKET CAP].
SELECT *, [INDEX MARKET CAP] * 100/SUM([INDEX MARKET CAP]) OVER() as [%]
FROM [S&P_Emerging_SmallCap_(US_Dollar)]
So, I get a sum of the [INDEX MARKET CAP], and then find the relative percentage of each items in the INDEX MARKET CAP. Great! now, I'm trying to modify the query a bit to give me the SUM of each relative INDEX MARKET CAP. So, the sum will be 100%! I just want to prove that the query works.
I'm trying to follow the example here.
http://technet.microsoft.com/en-us/library/ms190766%28v=sql.105%29.aspx
It seems so simple, but this dang thing just won't work.
I think it should be something like this.
;With CTE (Company, [%]) AS SELECT *, [INDEX MARKET CAP] * 100/SUM([INDEX MARKET CAP]) OVER() as [%] FROM [S&P_Emerging_SmallCap_(US_Dollar)] Select Company, SUM([%]) as Total FROM CTE Group By Company, Total
I keep getting this.
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'SELECT'.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.