SQL: Is it possible to 'group by' according to 'like' function's results?
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 with one of the columns is a huge string. And I am counting the number of rows matching particular patterns: SELECT m.str, count(*) FROM MESA m WHERE m.str LIKE '%FRUIT%' AND (m.str LIKE '%APPLE%' OR m.str LIKE '%ORANGE%') So let's assume the result of this query is: FRUIT..afsafafasfa...RED_APPLE 20 FRUIT..afsafafasfa...YELLOW_APPLE 12 FRUIT..afsafafasfa...GREEN_APPLE 3 FRUIT..afsafafasfa...PURPLE_ORANGE 4 FRUIT..afsafafasfa...RED_ORANGE 45