Query editor
WITH x AS (SELECT * FROM dune.canaryone.result_cpops_dvntype_log WHERE test_flag = '')SELECT dvn_type, w AS window_label,count_if(change = 'ADDED') AS routes_added, count_if(change = 'REMOVED') AS routes_removed,count(DISTINCT IF(change = 'ADDED', oapp)) AS apps_adding, count(DISTINCT IF(change = 'REMOVED', oapp)) AS apps_removing,count_if(change = 'REMOVED' AND move = 'left Canary on route') AS removals_left_canary,count_if(change = 'REMOVED' AND move = 'switched to other Canary type') AS removals_switched_typeFROM x CROSS JOIN UNNEST(ARRAY['all time', 'last 90d', 'last 30d']) AS u(w)WHERE w = 'all time' OR (w = 'last 90d' AND time_uk >= now() - INTERVAL '90' DAY) OR (w = 'last 30d' AND time_uk >= now() - INTERVAL '30' DAY)GROUP BY 1, 2 ORDER BY 2, min(dvn_type_sort)