用sql语句直接实现:百分比效果
select rownum 序号,k.* from (select nvl(temp.类型,'未知') 类型 ,sum(temp.件数) 件数,
to_char(round(ratio_to_report(sum(temp.件数)) over(partition by count(1)),4)*100,'fm999990.99999')||'%' as 百分比
from ( select '手机' 类型,count(*) 件数 from CRM_TL_CALL d
union all
select '电脑' 类型,count(*) 件数 from mobilephone d
) temp group by temp.类型,temp.件数
union all
SELECT '合计' typename,sum(total),'100%' FROM
(select count(*) total from CRM_TL_CALL d
union all
select count(*) total from mobilephone d
))k