|
Home > Archive > PostgreSQL SQL > December 2006 > retrieve row number
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
retrieve row number
|
|
| Pascal Tufenkji 2006-12-01, 5:41 am |
| Hi,
Can I retrieve the row number in a select statement?
For example : if I have the following table "foo"
col1 | col2
-----+-----
a | x
b | y
c | z
select ?? as row_number, col1, col2 from foo;
I should obtain the following result :
row_number | col1 | col2
-----------+------+-----
1 | a | x
2 | b | y
3 | c | z
Thank you
Pascal
| |
| A. Kretschmer 2006-12-01, 5:41 am |
| 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
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
|
|
|
|
|