I am using Oracle SQL and I want to group some different rows that \'like\' function results. To elaborate with an example:
Let\'s assume I have a table MESA w
Another variant of David Markle answer:
SELECT
fruit_name,
count(1) as fruit_count
FROM (
SELECT
CASE
WHEN m.str LIKE '%APPLE%' THEN 'Apple'
WHEN m.str LIKE '%ORANGE%' THEN 'Orange'
END as fruit_name
FROM
MESA m
WHERE
m.str LIKE '%FRUIT%'
AND
(m.str LIKE '%APPLE%' OR m.str LIKE '%ORANGE%')
)
GROUP BY
fruit_name
Same thing, but only 1 CASE required, which simplifies support ...