Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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:
There's lots of neat things you can do with window functions.


In response to

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group