From 4e062d06258b9e818083b99dcfb94682452d5acf Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 19 Mar 2019 00:22:00 -0400 Subject: [PATCH] rework basket --- route_sql/scenario_package.sql | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/route_sql/scenario_package.sql b/route_sql/scenario_package.sql index e1af6bc..eba121b 100644 --- a/route_sql/scenario_package.sql +++ b/route_sql/scenario_package.sql @@ -45,20 +45,27 @@ GROUP BY ,bill_cust_descr ,ship_cust_descr ) -, basket AS ( +, basket1 AS ( SELECT part_descr ,bill_cust_descr ,ship_cust_descr - ,SUM(value_usd)/(SELECT SUM(value_usd) FROM baseline) mix + ,SUM(value_usd) value_usd FROM base GROUP BY part_descr ,bill_cust_descr ,ship_cust_descr - ORDER BY - mix desc +) +,basket AS ( + SELECT + part_descr + ,bill_cust_descr + ,ship_cust_descr + ,value_usd/sum(value_usd) over () mix + FROM + basket1 ) ,months AS ( SELECT