Hi,
I have three fields: Currency, Cusip and Balance. I group by Currency and Cusip and sum the balance.
I want to select the top 5 cusips and their respective balances per currency. Can you do several Top 5's in the one sql statement without having to do a union and a whole lot of select statements( the currency field has over 30 values )?
Something like
I know that is not correct but Im not where to start or If it can be done in SQL.
Any thoughts?
Thanks
Mordja
I have three fields: Currency, Cusip and Balance. I group by Currency and Cusip and sum the balance.
I want to select the top 5 cusips and their respective balances per currency. Can you do several Top 5's in the one sql statement without having to do a union and a whole lot of select statements( the currency field has over 30 values )?
Something like
Code:
Select Top 5 A.Currency, A.Cusip, Sum(A.Balance) as Total
From TableName as A,(Select Distinct Currecncy From Tablename) as B
Where A.Currency = B.Currency
Group By A.Currency, A.Cusip
I know that is not correct but Im not where to start or If it can be done in SQL.
Any thoughts?
Thanks
Mordja