pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedretrieve row number
2+ messages / 2 participants
[nested] [flat]
* retrieve row number
@ 2006-12-01 06:31 Pascal Tufenkji <ptufenkji@usj.edu.lb>
2006-12-01 06:56 ` Re: retrieve row number A. Kretschmer <andreas.kretschmer@schollglas.com>
0 siblings, 1 reply; 2+ messages in thread
From: Pascal Tufenkji @ 2006-12-01 06:31 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: retrieve row number
2006-12-01 06:31 retrieve row number Pascal Tufenkji <ptufenkji@usj.edu.lb>
@ 2006-12-01 06:56 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
0 siblings, 0 replies; 2+ messages in thread
From: A. Kretschmer @ 2006-12-01 06:56 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-12-01 06:56 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-12-01 06:31 retrieve row number Pascal Tufenkji <ptufenkji@usj.edu.lb>
2006-12-01 06:56 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
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