日期:2014-05-18  浏览次数:20721 次

oralce数据库中相除取值问题
select sum(detail.ypghs),sum(detail.jsjhs),sum(detail.rghs),sum(detail.yipghs)" +
",sum(detail.yipghs)/sum(detail.ypghs),sum(detail.jzhs),sum(detail.dchs),sum(detail.jchs),sum(detail.fkhs)" +
",sum(detail.wtshs),sum(detail.zjsk),sum(detail.bs),sum(detail.fk),sum(detail.jsznj),sum(detail.zzs),sum(detail.xfs)" +
",sum(detail.qysds),sum(detail.wzqysds),sum(detail.bjsk) from KjNspgtjDetail detail where detail.baseId in ("+idStr+")";
这个语句中sum(detail.yipghs)/sum(detail.ypghs)中怎么让它保留两位小数啊
当yipghs=5,ypghs=10时为什么除出来的什是.5而不是0.5啊 怎么改????
请教各位高手!!!

------解决方案--------------------
round(x,y) 四舍五入
trunc(x,y) 直接截取