I have a a query that needs to do a count on a column where 2 other columns are true.
I need to Count ‘DealerName’ when ‘DealerName’ like ‘%MINI%’ AND ‘DealerContact_Y’ = 1
But I am unsure of the syntax. This query produces an error
SELECT DealerName,
count(DealerShipId) as dealersContacted,
CASE WHEN
DealerName LIKE "%MINI%", WHEN DealerContact_Y = 1
THEN Count(DealerContact_Y) END as Mini_contacted_yes,
Campaign,
DealerId
FROM tblsummaryResults
IS there a way to do mutiple WHENS in a case statement?
You would write it this way using
DealerName LIKE '%MINI%' AND DealerContact_Y = 1: