pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roland Roberts <roland@astrofoto.org>
To: pgsql-sql@postgresql.org
Subject: Re: How to select and result row number??
Date: 17 Sep 2002 10:14:58 -0400
Message-ID: <m265x4r9ct.fsf@kuiper.rlent.pnet> (raw)
In-Reply-To: <001301c25b5a$2ef0ea40$8a01a8c0@yudie>
References: <001301c25b5a$2ef0ea40$8a01a8c0@yudie>

>>>>> "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



view thread (9+ messages)  latest in thread

Message-ID: <m265x4r9ct.fsf@kuiper.rlent.pnet>
Permalink:  ../m265x4r9ct.fsf@kuiper.rlent.pnet/
Also on:    postgresql.org/message-id/m265x4r9ct.fsf@kuiper.rlent.pnet

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: roland@astrofoto.org
  Subject: Re: How to select and result row number??
  In-Reply-To: <m265x4r9ct.fsf@kuiper.rlent.pnet>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox