Re: retrieve row number

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: retrieve row number
Date: 2006-12-01 06:56:20
Message-ID: 20061201065620.GB1628@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

am Fri, dem 01.12.2006, um 8:31:41 +0200 mailte Pascal Tufenkji folgendes:
> Hi,
>
>
>
> Can I retrieve the row number in a select statement?
> For example : if I have the following table ?foo?
> I should obtain the following result :
>
>
>
> row_number | col1 | col2
> -----------+------+-----
> 1 | a | x
> 2 | b | y
> 3 | c | z

test=> create temporary sequence tmp_seq;
CREATE SEQUENCE
test=*> select nextval('tmp_seq') as row_number, col1, col2 from foo;
row_number | col1 | col2
------------+------+------
1 | a | x
2 | b | y
3 | c | z
(3 rows)

--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Juenemann 2006-12-01 13:37:55 Set binary column dependent on cumulative value of integer column
Previous Message Pascal Tufenkji 2006-12-01 06:31:41 retrieve row number