select sum(`value`) from testtable where value != 'error' AND type ='b' in (select DISTINCT(type) from testtable);
SELECT type,subtype,SUM(value) AS TOTNUM FROM testtable WHERE value !='error' GROUP BY type,subtype;
SELECT type,subtype,COUNT(value) AS TOTNUM FROM testtable WHERE value ='error' GROUP BY type,subtype;
select * from (select type,subtype,sum(case when value <> 'error' then value else '0' end) as 总数 ,sum(case when value = 'error' then 1 else '0' end) as error行数 from testtable group by type,subtype) t ORDER BY 总数 desc