
SELECT
    store_id,
    SUM(IF( msl = '1' AND present IN ('Y', 'N'), 1, 0)) AS Total_Y_N,
    SUM(IF(msl = '1' AND present = 'Y', 1, 0)) AS Total_Y,
    ROUND(
        (SUM(IF(msl = '1' AND present = 'Y', 1, 0)) * 100.0) /
        NULLIF(SUM(IF(msl = '1' AND present IN ('Y', 'N'), 1, 0)), 0),2
    ) AS Promo_Percentage
FROM DaburIndia_BI.Promotion
--WHERE visit_date >= '2026-04-01'
GROUP BY store_id
HAVING SUM(IF(msl = '1' AND present IN ('Y', 'N'), 1, 0)) > 0 
ORDER BY store_id;
