Re: Probably simple answer

From: "Command Prompt, Inc(dot)" <pgsql-general(at)commandprompt(dot)com>
To: Al Kirkus <Al(at)dist102(dot)k12(dot)il(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Probably simple answer
Date: 2001-11-06 00:27:16
Message-ID: Pine.LNX.4.30.0111051625540.9889-100000@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

You could either select the oid along with your query, or alternatively
set up a sequence:

http://www.postgresql.info/r23450.htm

Sincerely,

Joshua Drake
Co-Author: Practical PostgreSQL

On Thu, 1 Nov 2001, Al Kirkus wrote:

> Hi all.
>
> 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.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
--
by way of pgsql-general(at)commandprompt(dot)com
http://www.postgresql.info/
http://www.commandprompt.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Command Prompt, Inc. 2001-11-06 00:30:33 Re: Drop column and multiple db query
Previous Message Command Prompt, Inc. 2001-11-06 00:20:59 Re: functions, shell script