前端之家收集整理的这篇文章主要介绍了
oracle占比函数ratio_to_report,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参考:
http://www.jb51.cc/article/p-ejklnlfe-we.html
SELECT "ROUND"([color=red]ratio_to_report(amount) over(),4)*100 AS ratio,VY.GKJB
FROM
(SELECT VX.GKJB,"SUM"(VX.AMOUNT) AS amount FROM
(SELECT (CASE
WHEN VI.GKJB > '4' THEN
'4'
ELSE
VI.GKJB
END) AS GKJB,"SUM"(VI.N_MONEYTODAY) AS amount FROM VI_LIB_INVENTORY_DAILY vi WHERE
"SUBSTR"(VI.S_ACCDATE,1,6) = '201606' AND VI.KJKMDM IN ('271','272') GROUP BY VI.GKJB ) vx
GROUP BY VX.GKJB) vy