WITH Fruits AS (
SELECT
CASE
WHEN m.str LIKE '%APPLE%' THEN 'Apple'
WHEN m.str LIKE '%ORANGE%' THEN 'Orange'
END AS FruitType
FROM MESA m
WHERE m.str LIKE '%FRUIT%')
SELECT FruitType, COUNT(*)
FROM Fruits
WHERE FruitType IN ('Apple', 'Orange')
GROUP BY FruitType;