From: | "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt> |
---|---|
To: | "Louis-David Mitterrand" <vindex+lists-pgsql-sql(at)apartia(dot)org>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: "compressing" consecutive values into one |
Date: | 2010-11-23 15:31:59 |
Message-ID: | 5678C0F3BD5E48F587D8065C9C38BAA9@marktestcr.marktest.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Salut, Louis-David,
Can you please state the columns belonging to price table
and give a concrete example?
Say, data before and data after you want to do?
Thank you
A bien-tôt,
Oliveiros
----- Original Message -----
From: "Louis-David Mitterrand" <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: <pgsql-sql(at)postgresql(dot)org>
Sent: Tuesday, November 23, 2010 3:19 PM
Subject: [SQL] "compressing" consecutive values into one
> Hi,
>
> On time series price data I'm trying to remove consecutive identical
> prices and keep only the latest. I tried:
>
> delete from price where id_price in (select t.id_price2 from (select
> first_value(p.id_price) over w as id_price1,
> nth_value(p.id_price, 2) over w as id_price2,
> first_value(p.price) over w as price1,
> nth_value(p.price,2) over w as price2
> from price p
> window w as (partition by p.id_rate,p.id_cabin_category,p.id_cruise
> order by p.id_price desc rows between unbounded preceding and
> unbounded following)) as t where price1 = price2);
>
> and it mostly works but I have to do several runs to completely
> eliminate identical consecutive prices.
>
> Is there a better, one-pass, way?
>
> Thanks,
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
From | Date | Subject | |
---|---|---|---|
Next Message | Louis-David Mitterrand | 2010-11-23 18:13:29 | Re: "compressing" consecutive values into one |
Previous Message | Louis-David Mitterrand | 2010-11-23 15:19:19 | "compressing" consecutive values into one |