Listing A
SELECT
sales_rep_id, customer_id, order_total,
ratio_to_report(order_total) OVER () pct_total
FROM
orders
WHERE
sales_rep_id = 163
ORDER BY
sales_rep_id, customer_id, order_id
/
SQL> @ratioreport_a
SALES_REP_ID CUSTOMER_ID ORDER_TOTAL PCT_TOTAL
------------ ----------- ----------- ----------
163 102 5610.6 .043747539
163 102 10523 .082051002
163 103 78 .00060819
163 103 13550 .105653433
163 105 1926.6 .015022281
163 106 5546.6 .043248512
163 117 3878.4 .030241054
163 147 1500.8 .01170219
163 149 9055 .070604564
163 156 68501 .53412294
163 157 7110.3 .055441152
163 160 969.2 .007557144
12 rows selected.
SQL>
用户评论