Re: Ordering Results by a Supplied Order

From: Rémi Cura <remi(dot)cura(at)gmail(dot)com>
To: Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>
Cc: Michael Sacket <msacket(at)gammastream(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Ordering Results by a Supplied Order
Date: 2014-02-06 09:00:08
Message-ID: CAJvUf_txfY+JosctEcbxDnKa6Cr6V9COoWU1LOD2j=bjMre2_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey,
I don"t understand the difference between this ORDINALITY option and
adding a "row_number() over()" in the SELECT.

Thanks,

Cheers,
Remi-C

2014-02-06 Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>:

> On 02/06/2014 04:16 AM, Michael Sacket wrote:
>
> Often times I find it necessary to work with table rows in a specific,
> generally user-supplied order. It could be anything really that requires
> an ordering that can't come from a natural column. Most of the time this
> involved manipulating a position column from the client application. In
> any case, I've often found that to be cumbersome, but I think I've come up
> with a solution that some of you may find useful.
>
>
> Up until 9.4, that's a good way to do it.
>
> Starting from 9.4, you can use the WITH ORDINALITY feature.
> http://www.postgresql.org/docs/devel/static/sql-select.html
>
> --
> Vik
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message alexandros_e 2014-02-06 09:00:27 Re: Hard upgrade (everything)
Previous Message alexandros_e 2014-02-06 08:35:45 Re: Temporary table already exists