By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
--
-- Тестовый набор данных:
with
test1 (field1, field2) as
(
select '2020-12-01 01:54:40.112000' as field1, 1521.731812 as field2 union all
select '2020-12-01 01:54:41.112000' as field1, 1521.731812 as field2 union all
select '2020-12-01 01:54:42.112000' as field1, 1521.731812 as field2 union all
select '2020-12-01 01:54:43.112000' as field1, 1521.695557 as field2 union all
select '2020-12-01 01:54:44.112000' as field1, 1521.695557 as field2 union all
select '2020-12-01 01:54:45.112000' as field1, 1521.731812 as field2 union all
select '2020-12-01 01:54:46.112000' as field1, 1521.695557 as field2 union all
select '2020-12-01 01:54:47.112000' as field1, 1521.695557 as field2 union all
select '2020-12-01 01:55:18.112000' as field1, 1521.623291 as field2 union all
select '2020-12-01 01:55:19.112000' as field1, 1521.695557 as field2 union all
select '2020-12-01 01:55:49.112000' as field1, 1521.695557 as field2
)
--
-- Основной запрос:
select v.field1, v.field2
from (
select t0.field1, t0.field2
, (
select t1.field2
from test1 as t1
where t1.field1 < t0.field1
order by t1.field1 desc
limit 1
) as pev_field2
from test1 as t0
) as v
where case v.pev_field2
when v.field2 then 0
else 1
end = 1
field1 | field2 |
---|---|
2020-12-01 01:54:40.112000 | 1521.731812 |
2020-12-01 01:54:43.112000 | 1521.695557 |
2020-12-01 01:54:45.112000 | 1521.731812 |
2020-12-01 01:54:46.112000 | 1521.695557 |
2020-12-01 01:55:18.112000 | 1521.623291 |
2020-12-01 01:55:19.112000 | 1521.695557 |