Re: [SQL] Window function sort order help

2011-09-19 Thread Dianna Harter
Thank you. It works perfect. Dianna Tim Landscheidt < t...@tim-landscheidt.de > wrote: > If I understand the question correctly, try: > > | SELECT DISTINCT ON (consumer_id) consumer_id, move_date, history_timestamp > |FROM (SELECT consumer_id, move_date, history_timestamp, > |

Re: [SQL] Window function sort order help

2011-09-14 Thread Dianna Harter
Thank you. Interesting solution. Unfortunately, it's performance is not very good, since it involves joining a large table 3 times. I do have a solution that uses a temp table, but I was trying to rework it into a single query to improve performance. Thank you again for your help. Dianna

[SQL] Window function sort order help

2011-09-13 Thread Dianna Harter
Having trouble getting a window function to sort correctly. Given this data consumer_id | move_date | history_timestamp -++ 12345| 2008-01-05 | 2007-12-11 06:02:26.842171 12345| 2008-02-29 | 2008-02-05 07:22:38.04067 12