Re: ordering by date for each ID

From: Samuel Gendler <sgendler(at)ideasculptor(dot)com>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: ordering by date for each ID
Date: 2011-05-12 22:18:46
Message-ID: BANLkTimnzwnZD55MAM20V-PTekU9ds2CjA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, May 12, 2011 at 1:45 PM, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:

> Nguyen,Diep T wrote on 12.05.2011 03:59:
>
>>
>> Any help would be appreciated.
>>
>
> SELECT id,
> date,
> score_count,
> row_number() over (partition by id order by date desc) as order_value
> FROM your_table
>
>
>
Or the more general answer to your question is this:
http://www.postgresql.org/docs/8.4/interactive/functions-window.html
There's lots of neat things you can do with window functions.

--sam

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message R. Smith 2011-05-13 15:00:16 Sorting data based fields in two linked tables
Previous Message Thomas Kellerer 2011-05-12 20:45:21 Re: ordering by date for each ID