ลองเป็น
select o.spclty,sp.name as spname,
sum(if(o.pttype between '61' and '96',1,0)) as countUC,
sum(if(o.pttype between '61' and '96',vn.income,0)) as sumUC,
sum(if(o.pttype between '34' and '35',1,0)) as countSSM,
sum(if(o.pttype between '34' and '35',vn.income,0)) as sumSSM,
sum(if(o.pttype='22',1,0)) as countA2,
sum(if(o.pttype='22',vn.income,0)) as sumA2,
from ovst o
left outer join spclty sp on sp.spclty=o.spclty
left outer join vn_stat vn on vn.vn=o.vn
where o.vstdate between "2007-01-01" and "2007-01-31" and o.an IS NULL
group by sp.spclty
order by sp.spclty,o.vstdate
ลองประยุกต์ตามสิทธิอื่นๆดูครับ