Re: ordering by date for each ID - Mailing list pgsql-sql

From Samuel Gendler
Subject Re: ordering by date for each ID
Date
Msg-id BANLkTimnzwnZD55MAM20V-PTekU9ds2CjA@mail.gmail.com
Whole thread Raw
In response to Re: ordering by date for each ID  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-sql


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


pgsql-sql by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: ordering by date for each ID
Next
From: "R. Smith"
Date:
Subject: Sorting data based fields in two linked tables