SQL: Is it possible to 'group by' according to 'like' function's results?

前端 未结 5 1400
暖寄归人
暖寄归人 2021-02-20 13:44

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

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-20 14:43

    SELECT count(*) AS 'Apples'
    FROM MESA m
    WHERE m.str LIKE '%FRUIT%'
    AND m.str LIKE '%APPLE%'
    
    SELECT count(*) AS 'Oranges'
    FROM MESA m
    WHERE m.str LIKE '%FRUIT%'
    AND m.str LIKE '%ORANGE%'
    

    Would that work?

提交回复
热议问题