SELECT CASE
    WHEN COUNT(*) >= 1
     AND SUM(CASE WHEN `status` = 0 THEN 1 ELSE 0 END) = COUNT(*)
    THEN 1 ELSE 0
END AS ok
FROM `mdp_entity`
WHERE `entity_code` = 'S3_INVENTORY';
