We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This solution here uses a normal RANK function with an Oracle Syntax, I think this solution I came up with is more self-explanatory and does not use ROWNUM- I thin ROWNUM is better used where you need a sequential numbering, I would not feel safe in using that one, rather this:
select max(earnings),count(employee_id)
from(
select earnings, employee_id,rank()over(order by earnings desc)rnk
from(
select max(months * salary) earnings, employee_id
from employee
group by employee_id
))
where rnk=1;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Top Earners
You are viewing a single comment's thread. Return to all comments →
This solution here uses a normal RANK function with an Oracle Syntax, I think this solution I came up with is more self-explanatory and does not use ROWNUM- I thin ROWNUM is better used where you need a sequential numbering, I would not feel safe in using that one, rather this:
select max(earnings),count(employee_id) from( select earnings, employee_id,rank()over(order by earnings desc)rnk from( select max(months * salary) earnings, employee_id from employee group by employee_id )) where rnk=1;