You are viewing a single comment's thread. Return to all comments →
True, better filter out all the unnecessary values first and then do the agregations..
Here's an oracle solution without group by and is generalized incase the question asks for the nth maximum (where Rank = n).
SELECT AVG(EARNINGS), COUNT(*) FROM(
SELECT MONTHS*SALARY AS EARNINGS, RANK() over (order by MONTHS * SALARY DESC) as RANK FROM EMPLOYEE
where RANK = 1