试试下面可以达到你要的结果 select a,count(a) count from t1 group by a
有点乱,不知道理解的对不对select a,sum(case a when 1 then (case instr(b,'a') when 0 then 0 else 1 end) when 2 then (case instr(b,'b') when 0 then 0 else 1 end) end) from t1 group by a
shark2004(伤心小丑) 是对的
我好意思理解错了,我问一下你的记录只有这两种对应关系吗?a=1 对应b中包含a,a=2 b中包含b
select a,sum(case a when 1 then (case instr(b,'a') when 0 then 0 else 1 end) when 2 then (case instr(b,'b') when 0 then 0 else 1 end) end) from t1 group by a对了
select a,count(a) count from t1 group by a
from t1
group by a
b中包含b
from t1
group by a对了