RE: [GENERAL] Row Nums

From: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>
To: Anand Surelia <anand(at)bytekinc(dot)com>, "Jose' Soares" <jose(at)sferacarta(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: RE: [GENERAL] Row Nums
Date: 1998-10-08 21:59:59
Message-ID: F10BB1FAF801D111829B0060971D839F461A41@cpsmail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: Anand Surelia [SMTP:anand(at)bytekinc(dot)com]
> Sent: Thursday, October 08, 1998 2:08 PM
> To: Jose' Soares
> Cc: pgsql-general(at)postgreSQL(dot)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

Browse pgsql-general by date

  From Date Subject
Next Message ArtFile Pte Ltd 1998-10-09 02:47:30 subscribe
Previous Message Bruce Momjian 1998-10-08 21:40:53 Re: [GENERAL] select * from table where oid = number;