oracle占比函数ratio_to_report

阅读更多
参考: http://blog.csdn.net/ningjieshuijing/article/details/5854495
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

你可能感兴趣的:(oracle)