你那个SQL有问题吧,都group分组了,select里也没有用count,sum这类的统计函数。
code=0数量:select country, channel,count(*) AS code0数量 from table where name='code' and value='0' group by country, channel
设备数量: select country, channel,count(distinct id) AS 设备数量 from table group by country, channel
要再计算 code0数量-设备数量x2 ,可以把上面两个SQL作为子查询进行联表,就能计算出来了 select country, channel, code0数量-设备数量*2 AS 问题数量 from .....
--
FROM 222.129.6.*