pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Dennis.Jiang@thomson.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Does Postgresql have a similar pseudo-column "ROWNUM" as
Date: Tue, 17 May 2005 12:01:03 -0500
Message-ID: <1116349263.22291.129.camel@state.g2switchworks.com> (raw)
In-Reply-To: <DCD4903594CCF34CAFE200BDF3448D8D5B291A@tshuscodenmbx01.ERF.THOMSON.COM>
References: <DCD4903594CCF34CAFE200BDF3448D8D5B291A@tshuscodenmbx01.ERF.THOMSON.COM>

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;




view thread (17+ messages)  latest in thread

Message-ID: <1116349263.22291.129.camel@state.g2switchworks.com>
Permalink:  ../1116349263.22291.129.camel@state.g2switchworks.com/
Also on:    postgresql.org/message-id/1116349263.22291.129.camel@state.g2switchworks.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: smarlowe@g2switchworks.com, Dennis.Jiang@thomson.com
  Subject: Re: Does Postgresql have a similar pseudo-column "ROWNUM" as
  In-Reply-To: <1116349263.22291.129.camel@state.g2switchworks.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox