From: | "Ian Harding" <ianh(at)tpchd(dot)org> |
---|---|
To: | <Al(at)dist102(dot)k12(dot)il(dot)us>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Probably simple answer |
Date: | 2001-11-05 17:06:03 |
Message-ID: | sbe65689.003@mail.tpchd.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 that would create a temporary table with a serial field in it, populate it with data based on your query, then return the data. The temp table would go away with the connection. A function could create the table but you would still have to query 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(at)tpchd(dot)org
>>> "Al Kirkus" <Al(at)dist102(dot)k12(dot)il(dot)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 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
From | Date | Subject | |
---|---|---|---|
Next Message | DC | 2001-11-05 17:21:12 | Howto change column length |
Previous Message | Stephan Szabo | 2001-11-05 17:02:20 | Re: request for advise |