SELECT CASE WHEN
    (SELECT COUNT(*) FROM `ado_s8_alert_record` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_alert_rule` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_data_source` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_detection_log` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_exception` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_notification_layer` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_notification_log` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_role_permission_config` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_rule_detection_state` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_scene_config` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_watch_rule` WHERE `tenant_id`=1) = 0
AND (SELECT COUNT(*) FROM `ado_s8_alert_record_bak_1_0_349`) >= 2
AND (SELECT COUNT(*) FROM `ado_s8_alert_rule_bak_1_0_349`) >= 1
AND (SELECT COUNT(*) FROM `ado_s8_data_source_bak_1_0_349`) >= 1
AND (SELECT COUNT(*) FROM `ado_s8_detection_log_bak_1_0_349`) >= 162451
AND (SELECT COUNT(*) FROM `ado_s8_exception_bak_1_0_349`) >= 42
AND (SELECT COUNT(*) FROM `ado_s8_notification_layer_bak_1_0_349`) >= 2
AND (SELECT COUNT(*) FROM `ado_s8_notification_log_bak_1_0_349`) >= 1862
AND (SELECT COUNT(*) FROM `ado_s8_role_permission_config_bak_1_0_349`) >= 1
AND (SELECT COUNT(*) FROM `ado_s8_rule_detection_state_bak_1_0_349`) >= 17
AND (SELECT COUNT(*) FROM `ado_s8_scene_config_bak_1_0_349`) >= 7
AND (SELECT COUNT(*) FROM `ado_s8_watch_rule_bak_1_0_349`) >= 63
AND (
    SELECT COUNT(*)
    FROM `ado_s8_exception`
    WHERE `tenant_id`=797403760988230
      AND `factory_id`<>797403760988231
) = 0
THEN 1 ELSE 0 END AS ok;
