Question

select * from (select sum(dpt_no) as numbers from department group by dpt_name) order by numbers desc

Result:

  NUMBERS
----------
       420 
       209 
       106 
       105 
       103 
       102 

How to give ranks to this result?

Était-ce utile?

La solution

Please try:

select 
    numbers,
    rank() over(order by numbers desc) Rank
from (
    select sum(dpt_no) as numbers 
    from department group by dpt_name
) 
order by numbers desc

sample:

select 
  Col,
  rank() over(order by Col desc) Rank
From YourTable

SQL Fiddle Demo

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top