Re: getting the ranks of items - Mailing list pgsql-general

From Harald Fuchs
Subject Re: getting the ranks of items
Date
Msg-id pu3bt35j8e.fsf@srv.protecting.net
Whole thread Raw
In response to getting the ranks of items  (merlyn@stonehenge.com (Randal L. Schwartz))
Responses Re: getting the ranks of items
List pgsql-general
In article <427821D7.7070302@sysmaster.com>,
Lyubomir Petrov <lpetrov@sysmaster.com> writes:

> create sequence seq_tmp;
> select nextval('seq_tmp') as rank, a.id, a.name from (select id, name
> from t order by name desc) a;
> drop sequence seq_tmp;

Using a temporary sequence for that would avoid naming conflicts.

> P.S. I'm sure you can wrap it in plperl stored procedure :)

Yes, prepending the ranking column in the application would be more efficient.
I wonder whether Randall knows Perl? ;-)

pgsql-general by date:

Previous
From: "Lipy Reis"
Date:
Subject: Postgre 8.0 for Linux i586
Next
From: "Greg Sabino Mullane"
Date:
Subject: Re: getting the ranks of items