Re: Does Postgresql have a similar pseudo-column "ROWNUM" as - Mailing list pgsql-sql

From Scott Marlowe
Subject Re: Does Postgresql have a similar pseudo-column "ROWNUM" as
Date
Msg-id 1116349263.22291.129.camel@state.g2switchworks.com
Whole thread Raw
In response to Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle?  (<Dennis.Jiang@thomson.com>)
Responses Re: Does Postgresql have a similar pseudo-column "ROWNUM" as
List pgsql-sql
On Thu, 2005-05-12 at 14:07, Dennis.Jiang@thomson.com wrote:
> Hi:
> 
> Oracle has a pseudo-column "ROWNUM" to return the sequence number in which a row was returned when selected from a
table.The first row ROWNUM is 1, the second is 2, and so on.
 
> 
> Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle? If so, we can write the following query:
> 
> select * 
> from (select RowNum, pg_catalog.pg_proc.* 
>         from pg_catalog.pg_proc) inline_view
> where RowNum between 100 and 200;

You can get a functional equivalent with a temporary sequence:

create temp sequence rownum;
select *, nextval('rownum') as rownum from sometable;



pgsql-sql by date:

Previous
From: "Sim Zacks"
Date:
Subject: plpython setof
Next
From: Andrew Sullivan
Date:
Subject: Re: Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle?