Re: How to select and result row number?? - Mailing list pgsql-sql

From Roland Roberts
Subject Re: How to select and result row number??
Date
Msg-id m265x4r9ct.fsf@kuiper.rlent.pnet
Whole thread Raw
In response to How to select and result row number??  ("Yudie" <yudie@axiontech.com>)
Responses Re: How to select and result row number??
List pgsql-sql
>>>>> "Yudie" == Yudie  <yudie@axiontech.com> writes:
   Yudie> what is the select statement so I can get result records like this
   Yudie> no   cityname   Yudie> ----  --------------   Yudie> 1     NEW YORK   Yudie> 2     LOS ANGELES   Yudie> 3
HOUSTON  Yudie> 4     ....   Yudie> 5     ...
 

This is not really a SQL type result; you are probably better of
writing something in a procedural language.  That said, something like
this seems to work for 7.2:
   create sequence temp_counter;   select nextval('temp_counter'), * from whatever;

If you have an 'order by', the above will not work.  You could then
try either building a temporary table or using a subselect
   select nextval('temp_counter'), * from (select .... order by ...);

roland
--            PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
roland@rlenter.com                     76-15 113th Street, Apt 3B
roland@astrofoto.org                       Forest Hills, NY 11375


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Dublicates pairs in a table.
Next
From: "Robert J. Sanford, Jr."
Date:
Subject: Join Question