Re: How to realize ROW_NUMBER() in 8.3?

From: "Wappler, Robert" <rwappler(at)ophardt(dot)com>
To: <emilu(at)encs(dot)concordia(dot)ca>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to realize ROW_NUMBER() in 8.3?
Date: 2011-04-29 06:52:54
Message-ID: C8E2DAF0E663A948840B04023E0DE32A032D0262@w2k3server02.de.ophardt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2011-04-20, Emi Lu wrote:

> Hello,
>
> ROW_NUMBER() is only ready in 8.4. For 8.3, is there a simple
> way to get
> row_number
>
> select row_number(), col1, col2...
> FROM tableName
>

You definitely want to skim through the SQL Cookbook
(http://www.oreilly.de/catalog/9780596009762/) for this and many other
things.

Iirc, it suggested a set of CTEs that were joined together and grew
exponentially to get the sequence of numbers, which where finally joined
to the actual query. Pretty elegant and with tailored solutions for
various RDBMS including Postgres.

--
Robert...

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Toby Corkindale 2011-04-29 07:23:35 Re: SSDs with Postgresql?
Previous Message Alban Hertroys 2011-04-29 06:48:21 Re: schemas for organizing tables