Re: How to realize ROW_NUMBER() in 8.3?

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to realize ROW_NUMBER() in 8.3?
Date: 2011-05-04 05:28:36
Message-ID: 20110504052836.GA5658@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:

> Thank you for the info.
>
> I found a simple way:
> ==========================
> [1] create SEQUENCE tmp start 7820;
> [2]
> insert into desti_table_name
> select nextval('tmp'),
> c1, c2... ... cN
> from t1 left join t2... ... tn
> where ... ...
>
> Just for people using 8.3, this is mimic row_number.

Not really... you have to reset the sequence after the select, and i'm
not sure about ordering the result.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tarlika Elisabeth Schmitz 2011-05-04 22:48:04 data import via COPY, Rules + Triggers
Previous Message Viktor Bojović 2011-05-03 22:27:52 function timeout