求百分比的问题 select SUM(case when isnull(t3.BAG16,'0')<>'0' then 1 else 0 end )as jiyao,
COUNT(1) as heji
from V_VAJ5 t1 join BBY1 t2 on t1.BBY05=t2.BBY05 join BAG1 t3 on t2.BBY01=t3.BBY01
where t1.VAJ46 between '2014-01-01' and '2014-01-30'
select * , cast(cast(jiyao*1.0/heji*100.0 as numeric(10,2)) as varchar)+'%' as '百分比' from (
select SUM(case when isnull(t3.BAG16,'0')<>'0' then 1 else 0 end )as jiyao,
COUNT(1) as heji
from V_VAJ5 t1 join BBY1 t2 on t1.BBY05=t2.BBY05 join BAG1 t3 on t2.BBY01=t3.BBY01
where t1.VAJ46 between '2014-01-01' and '2014-01-30') a