SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
with search_bad_data as ( select *, created_at - lag(created_at) over w < '00:00:10'::time and lag(action_id) over w != action_id as is_bad_after, lead(created_at) over w - created_at < '00:00:10'::time and lead(action_id) over w != action_id as is_bad_before from (values (1, '2022-01-01 12:00:00'::timestamp, 1), (2, '2022-01-01 12:00:05', 1), (2, '2022-01-01 12:00:06', 1), (1, '2022-01-01 12:00:09', 2), (2, '2022-01-01 12:00:10', 1), (2, '2022-01-01 12:00:15', 3), (2, '2022-01-01 12:00:16', 2), (2, '2022-01-01 12:00:17', 6) ) tmp(client_id, created_at, action_id) window w as (partition by client_id order by created_at) ) select client_id, created_at, action_id from search_bad_data where is_bad_after or is_bad_before;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear