I am trying to get the sum of the market values for each given CPTY. Each CPTY can have several market values. In my output list, i want to see the top 5 CPTYs, ordered by the sum of their market values.
SELECT TOP 5 CPTY, SUM( MKT_VAL ) AS MarketVal FROM Eod GROUP BY CPTY ORDER BY SUM( MKT_VAL ) DESC;
SELECT TOP 5 CPTY, SUM( MKT_VAL ) AS MarketVal FROM Eod GROUP BY CPTY ORDER BY MarketVal DESC;
It appears when I try to ORDER BY the Alias (MarketVal), Access asks for MarketVal parameter value. However, when I ORDER BY SUM( MKT_VAL ), the code executes fine. I can't understand why this is, can anyone tell me why?