SELECT
  (SELECT COUNT(*) FROM `ado_smart_ops_improvement_plan`
   WHERE `TenantId` IS NULL OR `TenantId` IN (0,1,1300000000001)) AS invalid_tenant,
  (SELECT COUNT(*) FROM `ado_smart_ops_improvement_plan`
   WHERE `FactoryId` <= 0 OR `FactoryId` = `TenantId`) AS invalid_factory,
  (SELECT COUNT(*) FROM information_schema.STATISTICS
   WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ado_smart_ops_improvement_plan'
     AND INDEX_NAME='uk_smart_ops_improve_tenant_plan') AS uk_plan_no,
  (SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS
   WHERE CONSTRAINT_SCHEMA=DATABASE() AND TABLE_NAME='ado_smart_ops_improvement_plan'
     AND CONSTRAINT_NAME='ck_improve_valid_tenant') AS ck_tenant,
  (SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS
   WHERE CONSTRAINT_SCHEMA=DATABASE() AND TABLE_NAME='ado_smart_ops_improvement_plan'
     AND CONSTRAINT_NAME='ck_improve_valid_factory') AS ck_factory;
