pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedobtaining row number of select
2+ messages / 2 participants
[nested] [flat]
* obtaining row number of select
@ 2002-02-12 02:23 Keith Keller <kkeller@speakeasy.net>
2002-02-19 01:26 ` Re: obtaining row number of select Christopher Kings-Lynne <chriskl@familyhealth.com.au>
0 siblings, 1 reply; 2+ messages in thread
From: kkeller@speakeasy.net @ 2002-02-12 02:23 UTC (permalink / raw)
To: pgsql-sql
So I'm trying to generate a pseudo-serial number of a select
statement on the fly, and I want to do so within the select
statement. I could do this programmatically, but I wish to
use the select statement so that I can use it in creating a
view.
So, I would like to do something like so:
select serial(),* from mytable order by 1;
But of course that won't work. :) Is there any way to
autovivify a serial-like column for a select statement?
(I've scoured the docs, and still can't find an answer.)
--keith
--
kkeller@speakeasy.net
public key: http://wombat.san-francisco.ca.us/kkeller/public_key
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/perl/fom
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: obtaining row number of select
2002-02-12 02:23 obtaining row number of select Keith Keller <kkeller@speakeasy.net>
@ 2002-02-19 01:26 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
0 siblings, 0 replies; 2+ messages in thread
From: Christopher Kings-Lynne @ 2002-02-19 01:26 UTC (permalink / raw)
To: Keith Keller <kkeller@speakeasy.net>; pgsql-sql
> So I'm trying to generate a pseudo-serial number of a select
> statement on the fly, and I want to do so within the select
> statement. I could do this programmatically, but I wish to
> use the select statement so that I can use it in creating a
> view.
>
> So, I would like to do something like so:
>
> select serial(),* from mytable order by 1;
>
> But of course that won't work. :) Is there any way to
> autovivify a serial-like column for a select statement?
> (I've scoured the docs, and still can't find an answer.)
What about:
create sequence "myseq";
create view "myview" as select nextval('myseq'), * from mytable order by 1;
I tried this myself and every time I select from it, the sequence value is
incremented.
Chris
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-02-19 01:26 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-12 02:23 obtaining row number of select Keith Keller <kkeller@speakeasy.net>
2002-02-19 01:26 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
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