select sum(case when type=1 then 1 else 0 end) as type1,
sum(case when type=3 then 1 else 0 end) as type3,
sum(1) as typetotal
from test
sum(case when type=3 then 1 else 0 end) as type3,
sum(1) as typetotal
from test
就这样写select (select sum(*) from test where type=1) as type1,
(select sum(*) from test where type=3) as type3,
sum(1) as typetotal
from test