Search Postgresql Archives

Re: getting the ranks of items

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <427821D7.7070302@xxxxxxxxxxxxx>,
Lyubomir Petrov <lpetrov@xxxxxxxxxxxxx> 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? ;-)


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux