Re: Probably simple answer

From: Masaru Sugawara <rk73(at)echna(dot)ne(dot)jp>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Probably simple answer
Date: 2001-11-06 22:25:07
Message-ID: 20011107072048.D1A3.RK73@echna.ne.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-11-06 22:49:26 Re: functions, shell script
Previous Message Eric Ridge 2001-11-06 22:20:12 Re: pg_dump and DEFAULT column values