Determining Rank

Поиск
Список
Период
Сортировка
От Don Drake
Тема Determining Rank
Дата
Msg-id 6c21003b05020319061f8bce45@mail.gmail.com
обсуждение исходный текст
Ответы Re: Determining Rank  (Michael Fuhr <mike@fuhr.org>)
Re: Determining Rank  (Michael Glaesemann <grzm@myrealbox.com>)
Список pgsql-sql
I have a query that shows the top N count(*)'s.

So it's basically:

select some_val, count(*) 
from big_table
group by some_val
order by count(*)
limit 50

Now, I would like to have the rank included in the result set.  The
first row would be 1, followed by 2, etc. all the way to 50.

I can do this in PHP, but stuffing it into the DB query makes other
things easier.

Any ideas?

Thanks.

-Don

-- 
Donald Drake
President
Drake Consulting
http://www.drakeconsult.com/
http://www.MailLaunder.com/
312-560-1574


В списке pgsql-sql по дате отправления:

Предыдущее
От: Edmund Bacon
Дата:
Сообщение: Re: getting back autonumber just inserted
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Determining Rank