oracle中计算百分比,并同时解决小数点前0不显示的问题

select a.catalog_name,decode(substr(trunc((a.s/b.count2),4)*100||'%',0,1),'.',replace(trunc((a.s/b.count2),4)*100||'%','.','0.'),trunc((a.s/b.count2),4)*100||'%') as percent
from

    (SELECT PARENT_NAME as catalog_name, sum(COUNTNUM) as s
      FROM RES_PRODUCT
     GROUP BY PARENT_NAME) a,
(SELECT sum(countnum) count2 from res_product) b

posted @ 2018-03-13 20:44  灏月天染  阅读(769)  评论(0编辑  收藏  举报