Re: [SQL] sequence number in a result

2008-10-09 Thread Relyea, Mike
> Is there a function or special system label I can use that would generate a sequence number in the returning result set? Would something like this work for you? CREATE TEMP SEQUENCE foo; SELECT a, b, c, nextval('foo') AS order FROM t1 ORDER BY a; Mike Relyea Product Development Engineer Xe

Re: [SQL] sequence number in a result

2008-10-09 Thread Tom Lane
"Campbell, Lance" <[EMAIL PROTECTED]> writes: > Is there a function or special system label I can use that would > generate a sequence number in the returning result set? The usual hack is a temporary sequence: regression=# create temp sequence s1; CREATE SEQUENCE regression=# select nextval('s1'

Re: [SQL] sequence number in a result

2008-10-09 Thread Oliveiros Cristina
: Thursday, October 09, 2008 5:48 PM Subject: Re: [SQL] sequence number in a result Howdy, Lance. I had that problem about a year ago, and AFAIK there is no solution, at least not in SQL Standard. What I did was something like SELECT a,b,c,count(y.a) as order FROM t1 x , t1 y WH

Re: [SQL] sequence number in a result

2008-10-09 Thread Oliveiros Cristina
ueVisitors\"," + "resumo1.\"IDSite\",resumo1.\"dtDate\",resumo1.\"IDSiteResume\",resumo1.\"IDWeboramaAccount\",resumo1.\"Visits\" - Original Message - From: Campbell, Lance To: pgsql-sql@postgresql.org Sent: Thurs

[SQL] sequence number in a result

2008-10-09 Thread Campbell, Lance
Say I have the following SQL statement: SELECT a, b, c FROM t1 ORDER BY a; Is there a function or special system label I can use that would generate a sequence number in the returning result set? Example: SELECT a, b, c, SOMELABEL as order FROM t1 ORDER BY a; Result: ab c