Thank you. It works perfect.
Dianna
Tim Landscheidt < tim@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,
> | LAG(move_date) OVER (PARTITION BY consumer_id ORDER BY consumer_id, history_timestamp) AS
previous_move_date
> | FROM consumer_hist) AS SubQuery
> | WHERE move_date IS DISTINCT FROM previous_move_date
> | ORDER BY consumer_id, history_timestamp DESC;
>
> Tim