Determining Rank - Mailing list pgsql-sql

From Don Drake
Subject Determining Rank
Date
Msg-id 6c21003b05020319061f8bce45@mail.gmail.com
Whole thread Raw
Responses Re: Determining Rank  (Michael Fuhr <mike@fuhr.org>)
Re: Determining Rank  (Michael Glaesemann <grzm@myrealbox.com>)
List 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 by date:

Previous
From: Edmund Bacon
Date:
Subject: Re: getting back autonumber just inserted
Next
From: Michael Fuhr
Date:
Subject: Re: Determining Rank