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,
> |                     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

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to