SELECT
COUNT(*)
FROM
netting_promotions
LEFT JOIN netting_promotion_descriptions ON netting_promotion_descriptions.promotion_id = netting_promotions.promotion_id
AND netting_promotion_descriptions.lang_code = 'es'
LEFT JOIN netting_storefronts_promotions AS storefronts_promotions ON storefronts_promotions.promotion_id = netting_promotions.promotion_id
LEFT JOIN netting_promotion_images ON netting_promotion_images.promotion_id = netting_promotions.promotion_id
AND netting_promotion_images.lang_code = 'es'
WHERE
1
AND status IN ('A')
AND (
storefronts_promotions.storefront_id = 1
OR storefronts_promotions.storefront_id IS NULL
)
AND netting_promotions.promotion_id NOT IN (25, 26, 27)
AND 1