Re: Probably simple answer - Mailing list pgsql-general

From Ian Harding
Subject Re: Probably simple answer
Date
Msg-id sbe65689.003@mail.tpchd.org
Whole thread Raw
In response to Probably simple answer  ("Al Kirkus" <Al@dist102.k12.il.us>)
List pgsql-general
I can't think of a simple answer.  I think you would need some kind of programmatic solution like a client side program
thatwould create a temporary table with a serial field in it, populate it with data based on your query, then return
thedata.  The temp table would go away with the connection.  A function could create the table but you would still have
toquery the resulting table since functions can't return query results directly yet. 



Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
mailto: ianh@tpchd.org

>>> "Al Kirkus" <Al@dist102.k12.il.us> 11/01/01 12:24PM >>>
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
queryresults. 

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@postgresql.org so that your
message can get through to the mailing list cleanly


pgsql-general by date:

Previous
From: PC Drew
Date:
Subject: Daylight Savings Time
Next
From: Stephan Szabo
Date:
Subject: Re: request for advise