Re: Window function sort order help - Mailing list pgsql-sql

From Dianna Harter
Subject Re: Window function sort order help
Date
Msg-id 25770AAABEA9A2499B5427E0DCEE9C9B44B1647ED5@BE262.mail.lan
Whole thread Raw
In response to Re: Window function sort order help  (Tim Landscheidt <tim@tim-landscheidt.de>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: select xpath ...
Next
From: boris
Date:
Subject: Re: select xpath ...