RE: [GENERAL] Row Nums - Mailing list pgsql-general

From Jackson, DeJuan
Subject RE: [GENERAL] Row Nums
Date
Msg-id F10BB1FAF801D111829B0060971D839F461A41@cpsmail
Whole thread Raw
List pgsql-general

> -----Original Message-----
> From:    Anand Surelia [SMTP:anand@bytekinc.com]
> Sent:    Thursday, October 08, 1998 2:08 PM
> To:    Jose' Soares
> Cc:    pgsql-general@postgreSQL.org
> Subject:    Re: [GENERAL] Row Nums
>
> Jose' Soares wrote:
>
> > Anand Surelia wrote:
> > >
> > > Hi,
> > > I want to display serial numbers of rows selected by a query. I
> can do
> > > this in Oracle by selecting a special attribute called 'rownum'
> (or
> > > 'rowno'). Can I do this in Postgres too? If not then is there any
> > > alternative in Postgres?
> > >
> > SELECT oid, * FROM tablename;
> >
> > Jose'
> >
>
> No I dont't want the oids but the serial number of a row in the
> present
> output of the query. For e.g in Oracle we have:
> select rownum,name from tablename;
>
> will give me,
>
> rownum | name
>
> 1           | Anand
> 2           | Jose' Soares
> 3           | Someone
>
> Thanks,
> Anand.
>
>
>
Try:
create sequence tmp_count;
select nextval('tmp_count') as rowcount, * from sometable_or_view;
drop sequence tmp_count;
        -DEJ


pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] select * from table where oid = number;
Next
From: ArtFile Pte Ltd
Date:
Subject: subscribe