-1

假设我有一张名为评论的表。此表中有一个文本列,其中包含作为文本字符串的完整评论。从这里我想对所有在 Text 列中包含单词“love”的评论进行计数,并且从同一个 SQL 查询中,还对所有在 Text 列中包含单词“hate”的评论进行计数。

4

1 回答 1

1

可能是条件总和:

select 
    Sum(case when review like '%love%' then 1 else 0 end) loveCount,
    sum(case when review like '%hate%' then 1 else 0 end) hateCount
from reviews
于 2021-09-26T20:19:17.597 回答