Re: How ad an increasing index to a query result? - Mailing list pgsql-general

From Chris Spotts
Subject Re: How ad an increasing index to a query result?
Date
Msg-id 001501ca4cf2$5e979730$1bc6c590$@com
Whole thread Raw
In response to How ad an increasing index to a query result?  (Josip <josip.2000@gmail.com>)
List pgsql-general
>
> SELECT a, nextval('c') as b
> FROM table1
> ORDER BY a DESC LIMIT 5;
>
> I.e., I want to pick the 5 largest entries from table1 and show them
> alongside a new index column that tells the position of the entry. For
> example:
>
>  a  | b
> --------
> 82 | 5
> 79 | 4
> 34 | 3
> 12 | 2
> 11 | 1
>
[Spotts, Christopher]
Sounds like you you want 8.4 and windowing functions like row_number().
(http://www.postgresql.org/docs/8.4/static/functions-window.html)
If you have 8.4.


pgsql-general by date:

Previous
From: Andrew Bailey
Date:
Subject: Re: How ad an increasing index to a query result?
Next
From: Alvaro Herrera
Date:
Subject: Re: Cannot start the postgres service