select a.t1, b.t2, c.t3, d.t4
from (select count(*) t1 from table where col like '%1%') a,
(select count(*) t2 from table where col like '%2%') b,
(select count(*) t3 from table where col like '%3%') c,
(select count(*) t4 from table where col like '%4%') d
这是竖的
select 't1', count(*) from table where col like '%1%'
union all
select 't2', count(*) from table where col like '%2%'
union all
select 't3', count(*) from table where col like '%3%'
union all
select 't4', count(*) from table where col like '%4%'
你是要实现每一行数据中的所有相同数的总和吗?所有行的1的总和;所有行2的总和...。是不!
这是横的
这是竖的
大致思路就是这样