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

原文地址:https://www.cnblogs.com/wangc04/p/8561817.html