Re: Probably simple answer - Mailing list pgsql-general

From Masaru Sugawara
Subject Re: Probably simple answer
Date
Msg-id 20011107072048.D1A3.RK73@echna.ne.jp
Whole thread Raw
In response to Re: Probably simple answer  (Masaru Sugawara <rk73@echna.ne.jp>)
List pgsql-general
On Wed, 07 Nov 2001 00:40:50 +0900
I wrote:


> On Thu, 01 Nov 2001 14:24:29 -0600
> "Al Kirkus" wrote:
>
>
> > Can anyone tell me how to get a sequential row count field in the output of a query?
> >
> > Say I want to query for all users in a table sorted by lastname and firstname.
> > I would like to include a column in my query called "rownum" which would uniquely
> > identify the row in the order of the query results.
> >
> > Like this:
> >
> > rownum =1   lastname=jones, firstname=john
> > rownum=2 lastname=smith, firstname=john
> >
> > etc.
> > I assume rownum should be some kind of function of expresion but I don't know what.
> >
> > Something like:
> >
> > Select ???? as rownum, lastname,firstname from users
> >          where xxx =xxx order by lastname, firsname.
> >
>
>
> Ugh, that sounds like an oracle command. Instead of a rownum,
> as I understand it, you need to use a sequence which has already
> mentioned by Joshua. A following query A or B is what you want
> to select, isn't it?
>
>


Note !
In case of multi access, you must create sequences with unique name
per user or client PC, and must make each user or each PC use an
allocated sequence, respectively. In addition, each user or each PC
mustn't execute more than two queries at one time.


Probably, It doesn't increase evenly if there happen to be multi access
to a sequence.




Masaru Sugawara


pgsql-general by date:

Previous
From: "Eric Ridge"
Date:
Subject: Re: pg_dump and DEFAULT column values
Next
From: Martín Marqués
Date:
Subject: Re: Sourceforge moving from PostgreSQL to Oracle