"compressing" consecutive values into one

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема "compressing" consecutive values into one
Дата
Msg-id 20101123151918.GA22094@apartia.fr
обсуждение исходный текст
Ответы Re: "compressing" consecutive values into one
Список pgsql-sql
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
unboundedfollowing)) 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,


В списке pgsql-sql по дате отправления:

Предыдущее
От: tv@fuzzy.cz
Дата:
Сообщение: Re: Howto "insert or update" ?
Следующее
От: "Oliveiros d'Azevedo Cristina"
Дата:
Сообщение: Re: "compressing" consecutive values into one