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,
> |
2011/9/13 Dianna Harter :
Hi,
> [snip]
> Any suggestions to get the order by to occur first then the partition by or
> maybe there another approach that I could use?
I tried to write the query without using the window:
SELECT `X`.`consumer_id`, `X`.`move_date` , `X`.`history_timestamp` ,
Dianna Harter wrote:
> 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 |
2011/9/14 Dianna Harter :
> [snip]
> Thank you again for your help.
You're welcome. Sorry about the syntax, but I could only try on
MySQL... and I was curious about the problem :)
Nicoletta
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http:
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
Nicoletta Maia, 14.09.2011 10:30:
SELECT `X`.`consumer_id`, `X`.`move_date` , `X`.`history_timestamp` ,
MIN( `Y`.`history_timestamp` ) AS `start_time`
FROM
`Table` AS `X`
JOIN
`Table` AS `Y`
ON `X`.`consumer_id` = `Y`.`consumer_id`
2011/9/13 Dianna Harter :
Hi,
> [snip]
> Any suggestions to get the order by to occur first then the partition by or
> maybe there another approach that I could use?
I tried to write the query without using the window:
SELECT `X`.`consumer_id`, `X`.`move_date` , `X`.`history_timestamp` ,
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