我在一列中有两个字符串。我想要数数。
LIKE '%Alpha%' and LIKE '%Beta'%
我希望得到它们出现在表格中的次数。我认为这很容易使用qazxsw大便,但它似乎没有运作。
你可以做聚合:
CASE
如果你想分开计数,那么你可以做条件聚合:
select count(*)
from table t
where col like '%Alpha%' and col like '%Beta%';
如果你想将它们彼此分开计算:
select sum(case when col like '%Alpha%' then 1 else 0 end) as AlphaCnt,
sum(case when col like '%Beta%' then 1 else 0 end) as BetaCnt
from table t;