delete from time_series_value where time_series_id in (select id from time_series where time_series_type is null OR branch_id is null); delete from time_series where time_series_type is null OR branch_id is null;