Re: How to select and result row number??

Поиск
Список
Период
Сортировка
От Roland Roberts
Тема Re: How to select and result row number??
Дата
Msg-id m265x4r9ct.fsf@kuiper.rlent.pnet
обсуждение исходный текст
Ответ на How to select and result row number??  ("Yudie" <yudie@axiontech.com>)
Ответы Re: How to select and result row number??
Список 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 по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Dublicates pairs in a table.
Следующее
От: "Robert J. Sanford, Jr."
Дата:
Сообщение: Join Question