From: Samuel Gendler <sgendler@ideasculptor.com>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: ordering by date for each ID
Date: Thu, 12 May 2011 15:18:46 -0700
Message-ID: <BANLkTimnzwnZD55MAM20V-PTekU9ds2CjA@mail.gmail.com> (raw)
In-Reply-To: <iqhgso$u61$1@dough.gmane.org>
References: <AC6F23A2BA13C347A59BDCBCFF41E27B6954E47BAC@UFEXCH-MBXCL03.ad.ufl.edu>
<iqhgso$u61$1@dough.gmane.org>
On Thu, May 12, 2011 at 1:45 PM, Thomas Kellerer <spam_eater@gmx.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sgendler@ideasculptor.com, spam_eater@gmx.net
Subject: Re: ordering by date for each ID
In-Reply-To: <BANLkTimnzwnZD55MAM20V-PTekU9ds2CjA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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