SELECT Fruit,
SUM(counter)
FROM ( SELECT CASE
WHEN m.str LIKE '%APPLE%'
THEN 'APPLE'
ELSE 'ORANGE'
END AS Fruit
COUNT(*) AS counter
FROM MESA m
WHERE m.str LIKE '%FRUIT%'
AND (m.str LIKE '%APPLE%' OR m.str LIKE '%ORANGE%')
GROUP BY m.str
)
GROUP BY Fruit