select a.ga_clcd clcd, b.ad_clnm clnm, sum(a.ga_gjmu) 제작비, sum(a.ga_wjmt) 원가,
sum(a.ga_gjmu) - sum(a.ga_wjmt) 내수액
((sum(a.ga_gjmu) - sum(a.ga_wjmt))*100)/sum(a.ga_gjmu) 내수율
from tr110t a, tr030t b
where a.ga_cgdt>='2003-04-01' and a.ga_cgdt>='2003-04-31'
and a.ga_clcd = b.ad_clcd
group by ga_clcd, ad_clnm
일럴때요
((sum(a.ga_gjmu) - sum(a.ga_wjmt))*100)/sum(a.ga_gjmu) 내수율
여기 나누는 sum(a.ga_gjmu) 가 0일때 에러가 나잖아요....
에러를 안내게 하려면 어찌하나요?
case (sum(a.ga_gjmu) when 0 then 0
else
((sum(a.ga_gjmu) - sum(a.ga_wjmt))*100)/sum(a.ga_gjmu)
end as 내수