From 06c545dbc6008018295add00ba7e8ddd3b001ea8 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 8 Apr 2019 16:24:55 -0400 Subject: [PATCH 1/9] update query to add new parts --- route_sql/build/clone_parts.sql | 349 ++++++++++++++++---------------- 1 file changed, 174 insertions(+), 175 deletions(-) diff --git a/route_sql/build/clone_parts.sql b/route_sql/build/clone_parts.sql index 0d8ece2..8b12ec3 100644 --- a/route_sql/build/clone_parts.sql +++ b/route_sql/build/clone_parts.sql @@ -9,179 +9,178 @@ repl AS ( SELECT * FROM - ( + ( VALUES - ('GAB12000DE2','Garden Bowl - Slate Blue','GAB12000A34C012LRTOQ'), - ('GAB14000DE2','Garden Bowl - Slate Blue','GAB14000A34C012LRTOT'), - ('GAB18000DE2','Garden Bowl - Slate Blue','GAB18000A34C006LRTOW'), - ('GAB22000DE2','Garden Bowl - Slate Blue','GAB22000A34C006LRTOZ'), - ('GAB12000BG3','Garden Bowl - Teal','GAB12000A34C012LRTOQ'), - ('GAB14000BG3','Garden Bowl - Teal','GAB14000A34C012LRTOT'), - ('GAB18000BG3','Garden Bowl - Teal','GAB18000A34C006LRTOW'), - ('GAB22000BG3','Garden Bowl - Teal','GAB22000A34C006LRTOZ'), - ('CNA06000A42','Caribbean Planter - Warm Gray','CNA06000A50C024LRCGA'), - ('CNA08000A42','Caribbean Planter - Warm Gray','CNA08000A50C024LRCGC'), - ('CNA06000F89','Caribbean Planter - Raspberry','CNA06000A50C024LRCGA'), - ('CNA08000F89','Caribbean Planter - Raspberry','CNA08000A50C024LRCGC'), - ('CNA10000F89','Caribbean Planter - Raspberry','CNA10000A42C012LRBXI'), - ('CNA12000F89','Caribbean Planter - Raspberry','CNA12000A42C012LRBXJ'), - ('CNA06000BG3','Caribbean Planter - Teal','CNA06000A50C024LRCGA'), - ('CNA08000BG3','Caribbean Planter - Teal','CNA08000A50C024LRCGC'), - ('CNA10000BG3','Caribbean Planter - Teal','CNA10000A42C012LRBXI'), - ('CNA12000BG3','Caribbean Planter - Teal','CNA12000A42C012LRBXJ'), - ('CNA06000A10','Caribbean Planter - White','CNA06000A50C024LRCGA'), - ('CNA08000A10','Caribbean Planter - White','CNA08000A50C024LRCGC'), - ('CNA10000A10','Caribbean Planter - White','CNA10000A42C012LRBXI'), - ('CNA12000A10','Caribbean Planter - White','CNA12000A42C012LRBXJ'), - ('CNA30000A10','Caribbean Planter - White','CNA30000G18C002LRCDG'), - ('LIA06000DE2','Classic Planter - Slate Blue','LIA06000A34C024LRTIV'), - ('LIA08000DE2','Classic Planter - Slate Blue','LIA08000A34C024LRTIZ'), - ('LIA10000DE2','Classic Planter - Slate Blue','LIA10000A34C012LRTJD'), - ('LIA12000DE2','Classic Planter - Slate Blue','LIA12000A34C012LRTJH'), - ('LIA14000DE2','Classic Planter - Slate Blue','LIA14000A34C012LRTJL'), - ('LIA16000DE2','Classic Planter - Slate Blue','LIA16000A34C006LRTJP'), - ('LIA20000DE2','Classic Planter - Slate Blue','LIA20000A34C006LRTJT'), - ('LIA24000DE2','Classic Planter - Slate Blue','LIA24000A34C006LRTJY'), - ('LIA06000B78','Classic Planter - Seafoam','LIA06000A34C024LRTIV'), - ('LIA08000B78','Classic Planter - Seafoam','LIA08000A34C024LRTIZ'), - ('LIA10000B78','Classic Planter - Seafoam','LIA10000A34C012LRTJD'), - ('LIA12000B78','Classic Planter - Seafoam','LIA12000A34C012LRTJH'), - ('LIA14000B78','Classic Planter - Seafoam','LIA14000A34C012LRTJL'), - ('LIA16000B78','Classic Planter - Seafoam','LIA16000A34C006LRTJP'), - ('LIA20000B78','Classic Planter - Seafoam','LIA20000A34C006LRTJT'), - ('LIA24000B78','Classic Planter - Seafoam','LIA24000A34C006LRTJY'), - ('SLI06000DE2','Classic Saucer - Slate Blue','SLI06000A34C024LRTKB'), - ('SLI08000DE2','Classic Saucer - Slate Blue','SLI08000A34C024LRTKF'), - ('SLI10000DE2','Classic Saucer - Slate Blue','SLI10000A34C012LRTKJ'), - ('SLI12000DE2','Classic Saucer - Slate Blue','SLI12000A34C012LAH13'), - ('SLI14000DE2','Classic Saucer - Slate Blue','SLI14000A34C012LAH16'), - ('SLI17000DE2','Classic Saucer - Slate Blue','SLI17000A34C012LAH19'), - ('SLI20000DE2','Classic Saucer - Slate Blue','SLI20000A34C006LAH24'), - ('SLI24000DE2','Classic Saucer - Slate Blue','SLI24000A34C006LRTLD'), - ('SLI06000B78','Classic Saucer - Seafoam','SLI06000A34C024LRTKB'), - ('SLI08000B78','Classic Saucer - Seafoam','SLI08000A34C024LRTKF'), - ('SLI10000B78','Classic Saucer - Seafoam','SLI10000A34C012LRTKJ'), - ('SLI12000B78','Classic Saucer - Seafoam','SLI12000A34C012LAH13'), - ('SLI14000B78','Classic Saucer - Seafoam','SLI14000A34C012LAH16'), - ('SLI16000B78','Classic Saucer - Seafoam','SAA14001A10C006LRCDJ'), - ('SLI20000B78','Classic Saucer - Seafoam','SLI20000A34C006LAH24'), - ('SLI24000B78','Classic Saucer - Seafoam','SLI24000A34C006LRTLD'), - ('ECA06000DE2','Eclipse Planter - Slate Blue','ECA06000A101009LRCIG'), - ('ECA08000DE2','Eclipse Planter - Slate Blue','ECA08000A101006LRCID'), - ('ECA10000DE2','Eclipse Planter - Slate Blue','ECA10000A341020LRCEL'), - ('ECA12000DE2','Eclipse Planter - Slate Blue','ECA12000A101006LRCIA'), - ('ECA16000DE2','Eclipse Planter - Slate Blue','ECA16000A34C010LRCEX'), - ('ECA20000DE2','Eclipse Planter - Slate Blue','ECA20000A341006LRCEU'), - ('ECA06000B78','Eclipse Planter - Seafoam','ECA06000A101009LRCIG'), - ('ECA08000B78','Eclipse Planter - Seafoam','ECA08000A101006LRCID'), - ('ECA10000B78','Eclipse Planter - Seafoam','ECA10000A341020LRCEL'), - ('ECA12000B78','Eclipse Planter - Seafoam','ECA12000A101006LRCIA'), - ('ECA16000B78','Eclipse Planter - Seafoam','ECA16000A34C010LRCEX'), - ('ECA20000B78','Eclipse Planter - Seafoam','ECA20000A341006LRCEU'), - ('GDP08000DE2','Hanging Garden Planter - Slate Blue','SAA14001A10C006LRCDJ'), - ('GDP08000BG3','Hanging Garden Planter - Teal','SAA14001A10C006LRCDJ'), - ('MSA12001DE2','Marina Planter - Slate Blue','MSA12001A341008LRCFQ'), - ('MSA16001DE2','Marina Planter - Slate Blue','MSA16001A34C004LRAYN'), - ('MSA20001DE2','Marina Planter - Slate Blue','MSA20001A34C004LRCFW'), - ('MSA12001A42','Marina Planter - Warm Gray','MSA12001A341008LRCFQ'), - ('MSA16001A42','Marina Planter - Warm Gray','MSA16001A34C004LRAYN'), - ('MSA20001A42','Marina Planter - Warm Gray','MSA20001A34C004LRCFW'), - ('MSA12001B78','Marina Planter - Seafoam','MSA12001A341008LRCFQ'), - ('MSA16001B78','Marina Planter - Seafoam','MSA16001A34C004LRAYN'), - ('MSA20001B78','Marina Planter - Seafoam','MSA20001A34C004LRCFW'), - ('SEA07001DE2','Sedona Planter - Slate Blue','SEA07001B15C008LRAZR'), - ('SEA09001DE2','Sedona Planter - Slate Blue','SEA09001B15C008LRAZS'), - ('SEA12001DE2','Sedona Planter - Slate Blue','SEA12001B15C006LRAZU'), - ('SEA14001DE2','Sedona Planter - Slate Blue','SEA14001B15C006LRAZT'), - ('SEA16000DE2','Sedona Planter - Slate Blue','SAA14001A10C006LRCDJ'), - ('SEA07001B78','Sedona Planter - Seafoam','SEA07001B15C008LRAZR'), - ('SEA09001B78','Sedona Planter - Seafoam','SEA09001B15C008LRAZS'), - ('SEA12001B78','Sedona Planter - Seafoam','SEA12001B15C006LRAZU'), - ('SEA14001B78','Sedona Planter - Seafoam','SEA14001B15C006LRAZT'), - ('SEA16000B78','Sedona Planter - Seafoam','SAA14001A10C006LRCDJ'), - ('SEA07001A42','Sedona Planter - Warm Gray','SEA07001B15C008LRAZR'), - ('SEA09001A42','Sedona Planter - Warm Gray','SEA09001B15C008LRAZS'), - ('SEA12001A42','Sedona Planter - Warm Gray','SEA12001B15C006LRAZU'), - ('SEA14001A42','Sedona Planter - Warm Gray','SEA14001B15C006LRAZT'), - ('SEA16000A42','Sedona Planter - Warm Gray','SAA14001A10C006LRCDJ'), - ('VNP18000A42','Venetian Flower Box - Warm Gray','VNP18000A34C006LRTPN'), - ('VNP24000A42','Venetian Flower Box - Warm Gray','VNP24000A34C006LRTPR'), - ('VNP30000A42','Venetian Flower Box - Warm Gray','VNP30000A34C006LRTPV'), - ('VNP18000A10','Venetian Flower Box - White','VNP18000A34C006LRTPN'), - ('VNP24000A10','Venetian Flower Box - White','VNP24000A34C006LRTPR'), - ('VNP30000A10','Venetian Flower Box - White','VNP30000A34C006LRTPV'), - ('SVN18000A42','Venetian Flower Box Tray - Warm Gray','SVN18000A34C006LRTPZ'), - ('SVN24000A42','Venetian Flower Box Tray - Warm Gray','SVN24000A34C006LRTQD'), - ('SVN30000A42','Venetian Flower Box Tray - Warm Gray','SVN30000A34C006LRTQH'), - ('SVN18000A10','Venetian Flower Box Tray - White','SVN18000A34C006LRTPZ'), - ('SVN24000A10','Venetian Flower Box Tray - White','SVN24000A34C006LRTQD'), - ('SVN30000A10','Venetian Flower Box Tray - White','SVN30000A34C006LRTQH'), - ('ASP06000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ASP08000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ASP10000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ASP12000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ASP16000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ASP06000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ASP08000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ASP10000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ASP12000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ASP16000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ASP06000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ASP08000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ASP10000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ASP12000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ASP16000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ASP06000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ASP08000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ASP10000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ASP12000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ASP16000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ARP06000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ARP08000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ARP10000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ARP12000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ARP16000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ'), - ('ARP06000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ARP08000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ARP10000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ARP12000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ARP16000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('ARP06000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ARP08000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ARP10000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ARP12000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ARP16000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('ARP06000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ARP08000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ARP10000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ARP12000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ARP16000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ'), - ('ANP12000A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ'), - ('ANP15000A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ'), - ('ANP17500A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ'), - ('CAS12000P26','Cascade Tall Square Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('CAS15000P26','Cascade Tall Square Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('CAS12000P80','Cascade Tall Square Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('CAS15000P80','Cascade Tall Square Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('CAR12000P26','Cascade Tall Round Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('CAR15000P26','Cascade Tall Round Planter - Black Onyx','SAA14001A10C006LRCDJ'), - ('CAR12000P80','Cascade Tall Round Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('CAR15000P80','Cascade Tall Round Planter - Glossy White','SAA14001A10C006LRCDJ'), - ('SKR12000G27','Santa Fe Round Planter - Black Sand','SAA14001A10C006LRCDJ'), - ('SKR16000G27','Santa Fe Round Planter - Black Sand','SAA14001A10C006LRCDJ'), - ('SKR12000E66','Santa Fe Round Planter - Cavern Clay','SAA14001A10C006LRCDJ'), - ('SKR16000E66','Santa Fe Round Planter - Cavern Clay','SAA14001A10C006LRCDJ'), - ('SKR12000A56','Santa Fe Round Planter - Pebble Gray','SAA14001A10C006LRCDJ'), - ('SKR16000A56','Santa Fe Round Planter - Pebble Gray','SAA14001A10C006LRCDJ'), - ('SKS12000G27','Santa Fe Square Planter - Black Sand','SAA14001A10C006LRCDJ'), - ('SKS16000G27','Santa Fe Square Planter - Black Sand','SAA14001A10C006LRCDJ'), - ('SKS12000E66','Santa Fe Square Planter - Cavern Clay','SAA14001A10C006LRCDJ'), - ('SKS16000E66','Santa Fe Square Planter - Cavern Clay','SAA14001A10C006LRCDJ'), - ('SKS12000A56','Santa Fe Square Planter - Pebble Gray','SAA14001A10C006LRCDJ'), - ('SKS16000A56','Santa Fe Square Planter - Pebble Gray','SAA14001A10C006LRCDJ'), - ('WBP16000P82','Whiskey Barrel Planter - Aged Oak','SAA14001A10C006LRCDJ'), - ('0','Planter Trellis 6-Pack - Black','SAA14001A10C006LRCDJ') - ) x("target","descr","clone") + ('GAB12000DE2','Garden Bowl - Slate Blue','GAB12000A34C012LRTOQ',0.93886), + ('GAB14000DE2','Garden Bowl - Slate Blue','GAB14000A34C012LRTOT',1.30893), + ('GAB18000DE2','Garden Bowl - Slate Blue','GAB18000A34C006LRTOW',2.04076), + ('GAB22000DE2','Garden Bowl - Slate Blue','GAB22000A34C006LRTOZ',3.54985), + ('GAB12000BG3','Garden Bowl - Teal','GAB12000A34C012LRTOQ',0.93886), + ('GAB14000BG3','Garden Bowl - Teal','GAB14000A34C012LRTOT',1.30893), + ('GAB18000BG3','Garden Bowl - Teal','GAB18000A34C006LRTOW',2.04076), + ('GAB22000BG3','Garden Bowl - Teal','GAB22000A34C006LRTOZ',3.54985), + ('CNA06000A42','Caribbean Planter - Warm Gray','CNA06000A50C024LRCGA',0.36037), + ('CNA08000A42','Caribbean Planter - Warm Gray','CNA08000A50C024LRCGC',0.44575), + ('CNA06000F89','Caribbean Planter - Raspberry','CNA06000A50C024LRCGA',0.36222), + ('CNA08000F89','Caribbean Planter - Raspberry','CNA08000A50C024LRCGC',0.45024), + ('CNA10000F89','Caribbean Planter - Raspberry','CNA10000A42C012LRBXI',0.65195), + ('CNA12000F89','Caribbean Planter - Raspberry','CNA12000A42C012LRBXJ',1.63119), + ('CNA06000BG3','Caribbean Planter - Teal','CNA06000A50C024LRCGA',0.36222), + ('CNA08000BG3','Caribbean Planter - Teal','CNA08000A50C024LRCGC',0.45024), + ('CNA10000BG3','Caribbean Planter - Teal','CNA10000A42C012LRBXI',0.65195), + ('CNA12000BG3','Caribbean Planter - Teal','CNA12000A42C012LRBXJ',1.63119), + ('CNA06000A10','Caribbean Planter - White','CNA06000A50C024LRCGA',0.35215), + ('CNA08000A10','Caribbean Planter - White','CNA08000A50C024LRCGC',0.44641), + ('CNA10000A10','Caribbean Planter - White','CNA10000A42C012LRBXI',0.64485), + ('CNA12000A10','Caribbean Planter - White','CNA12000A42C012LRBXJ',1.61797), + ('CNA30000A10','Caribbean Planter - White','CNA30000G18C002LRCDG',28.85), + ('LIA06000DE2','Classic Planter - Slate Blue','LIA06000A34C024LRTIV',0.35842), + ('LIA08000DE2','Classic Planter - Slate Blue','LIA08000A34C024LRTIZ',0.56212), + ('LIA10000DE2','Classic Planter - Slate Blue','LIA10000A34C012LRTJD',1.8113), + ('LIA12000DE2','Classic Planter - Slate Blue','LIA12000A34C012LRTJH',2.42383), + ('LIA14000DE2','Classic Planter - Slate Blue','LIA14000A34C012LRTJL',2.73708), + ('LIA16000DE2','Classic Planter - Slate Blue','LIA16000A34C006LRTJP',3.05778), + ('LIA20000DE2','Classic Planter - Slate Blue','LIA20000A34C006LRTJT',5.63275), + ('LIA24000DE2','Classic Planter - Slate Blue','LIA24000A34C006LRTJY',6.35725), + ('LIA06000B78','Classic Planter - Seafoam','LIA06000A34C024LRTIV',0.35842), + ('LIA08000B78','Classic Planter - Seafoam','LIA08000A34C024LRTIZ',0.56212), + ('LIA10000B78','Classic Planter - Seafoam','LIA10000A34C012LRTJD',1.8113), + ('LIA12000B78','Classic Planter - Seafoam','LIA12000A34C012LRTJH',2.42383), + ('LIA14000B78','Classic Planter - Seafoam','LIA14000A34C012LRTJL',2.73708), + ('LIA16000B78','Classic Planter - Seafoam','LIA16000A34C006LRTJP',3.05778), + ('LIA20000B78','Classic Planter - Seafoam','LIA20000A34C006LRTJT',5.63275), + ('LIA24000B78','Classic Planter - Seafoam','LIA24000A34C006LRTJY',6.35725), + ('SLI06000DE2','Classic Saucer - Slate Blue','SLI06000A34C024LRTKB',0.18237), + ('SLI08000DE2','Classic Saucer - Slate Blue','SLI08000A34C024LRTKF',0.29674), + ('SLI10000DE2','Classic Saucer - Slate Blue','SLI10000A34C012LRTKJ',0.54887), + ('SLI12000DE2','Classic Saucer - Slate Blue','SLI12000A34C012LAH13',0.72483), + ('SLI14000DE2','Classic Saucer - Slate Blue','SLI14000A34C012LAH16',0.99295), + ('SLI17000DE2','Classic Saucer - Slate Blue','SLI17000A34C012LAH19',1.10433), + ('SLI20000DE2','Classic Saucer - Slate Blue','SLI20000A34C006LAH24',1.0319), + ('SLI24000DE2','Classic Saucer - Slate Blue','SLI24000A34C006LRTLD',1.95471), + ('SLI06000B78','Classic Saucer - Seafoam','SLI06000A34C024LRTKB',0.18237), + ('SLI08000B78','Classic Saucer - Seafoam','SLI08000A34C024LRTKF',0.29674), + ('SLI10000B78','Classic Saucer - Seafoam','SLI10000A34C012LRTKJ',0.54887), + ('SLI12000B78','Classic Saucer - Seafoam','SLI12000A34C012LAH13',0.72483), + ('SLI14000B78','Classic Saucer - Seafoam','SLI14000A34C012LAH16',0.99295), + ('SLI16000B78','Classic Saucer - Seafoam','SAA14001A10C006LRCDJ',1.10433), + ('SLI20000B78','Classic Saucer - Seafoam','SLI20000A34C006LAH24',1.0319), + ('SLI24000B78','Classic Saucer - Seafoam','SLI24000A34C006LRTLD',1.95471), + ('ECA06000DE2','Eclipse Planter - Slate Blue','ECA06000A101009LRCIG',0.42036), + ('ECA08000DE2','Eclipse Planter - Slate Blue','ECA08000A101006LRCID',0.63429), + ('ECA10000DE2','Eclipse Planter - Slate Blue','ECA10000A341020LRCEL',0.92453), + ('ECA12000DE2','Eclipse Planter - Slate Blue','ECA12000A101006LRCIA',1.25858), + ('ECA16000DE2','Eclipse Planter - Slate Blue','ECA16000A34C010LRCEX',2.57535), + ('ECA20000DE2','Eclipse Planter - Slate Blue','ECA20000A341006LRCEU',4.17568), + ('ECA06000B78','Eclipse Planter - Seafoam','ECA06000A101009LRCIG',0.42036), + ('ECA08000B78','Eclipse Planter - Seafoam','ECA08000A101006LRCID',0.63429), + ('ECA10000B78','Eclipse Planter - Seafoam','ECA10000A341020LRCEL',0.92453), + ('ECA12000B78','Eclipse Planter - Seafoam','ECA12000A101006LRCIA',1.25858), + ('ECA16000B78','Eclipse Planter - Seafoam','ECA16000A34C010LRCEX',2.57535), + ('ECA20000B78','Eclipse Planter - Seafoam','ECA20000A341006LRCEU',4.17568), + ('GDP08000DE2','Hanging Garden Planter - Slate Blue','SAA14001A10C006LRCDJ',1.5), + ('GDP08000BG3','Hanging Garden Planter - Teal','SAA14001A10C006LRCDJ',1.5), + ('MSA12001DE2','Marina Planter - Slate Blue','MSA12001A341008LRCFQ',1.85199), + ('MSA16001DE2','Marina Planter - Slate Blue','MSA16001A34C004LRAYN',2.80127), + ('MSA20001DE2','Marina Planter - Slate Blue','MSA20001A34C004LRCFW',4.88869), + ('MSA12001A42','Marina Planter - Warm Gray','MSA12001A341008LRCFQ',1.85199), + ('MSA16001A42','Marina Planter - Warm Gray','MSA16001A34C004LRAYN',2.80127), + ('MSA20001A42','Marina Planter - Warm Gray','MSA20001A34C004LRCFW',4.88869), + ('MSA12001B78','Marina Planter - Seafoam','MSA12001A341008LRCFQ',1.85199), + ('MSA16001B78','Marina Planter - Seafoam','MSA16001A34C004LRAYN',2.80127), + ('MSA20001B78','Marina Planter - Seafoam','MSA20001A34C004LRCFW',4.88869), + ('SEA07001DE2','Sedona Planter - Slate Blue','SEA07001B15C008LRAZR',0.60131), + ('SEA09001DE2','Sedona Planter - Slate Blue','SEA09001B15C008LRAZS',0.91061), + ('SEA12001DE2','Sedona Planter - Slate Blue','SEA12001B15C006LRAZU',1.55347), + ('SEA14001DE2','Sedona Planter - Slate Blue','SEA14001B15C006LRAZT',2.14701), + ('SEA16000DE2','Sedona Planter - Slate Blue','SAA14001A10C006LRCDJ',2.51344), + ('SEA07001B78','Sedona Planter - Seafoam','SEA07001B15C008LRAZR',0.60131), + ('SEA09001B78','Sedona Planter - Seafoam','SEA09001B15C008LRAZS',0.91061), + ('SEA12001B78','Sedona Planter - Seafoam','SEA12001B15C006LRAZU',1.55347), + ('SEA14001B78','Sedona Planter - Seafoam','SEA14001B15C006LRAZT',2.14701), + ('SEA16000B78','Sedona Planter - Seafoam','SAA14001A10C006LRCDJ',2.51344), + ('SEA07001A42','Sedona Planter - Warm Gray','SEA07001B15C008LRAZR',0.60131), + ('SEA09001A42','Sedona Planter - Warm Gray','SEA09001B15C008LRAZS',0.91061), + ('SEA12001A42','Sedona Planter - Warm Gray','SEA12001B15C006LRAZU',1.55347), + ('SEA14001A42','Sedona Planter - Warm Gray','SEA14001B15C006LRAZT',2.14701), + ('SEA16000A42','Sedona Planter - Warm Gray','SAA14001A10C006LRCDJ',2.51344), + ('VNP18000A42','Venetian Flower Box - Warm Gray','VNP18000A34C006LRTPN',1.44406), + ('VNP24000A42','Venetian Flower Box - Warm Gray','VNP24000A34C006LRTPR',1.63875), + ('VNP30000A42','Venetian Flower Box - Warm Gray','VNP30000A34C006LRTPV',2.31994), + ('VNP18000A10','Venetian Flower Box - White','VNP18000A34C006LRTPN',1.44406), + ('VNP24000A10','Venetian Flower Box - White','VNP24000A34C006LRTPR',1.63875), + ('VNP30000A10','Venetian Flower Box - White','VNP30000A34C006LRTPV',2.31994), + ('SVN18000A42','Venetian Flower Box Tray - Warm Gray','SVN18000A34C006LRTPZ',0.94787), + ('SVN24000A42','Venetian Flower Box Tray - Warm Gray','SVN24000A34C006LRTQD',1.04921), + ('SVN30000A42','Venetian Flower Box Tray - Warm Gray','SVN30000A34C006LRTQH',1.25193), + ('SVN18000A10','Venetian Flower Box Tray - White','SVN18000A34C006LRTPZ',0.94787), + ('SVN24000A10','Venetian Flower Box Tray - White','SVN24000A34C006LRTQD',1.04921), + ('SVN30000A10','Venetian Flower Box Tray - White','SVN30000A34C006LRTQH',1.25193), + ('ASP06000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',0.852601662887377), + ('ASP08000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',1.4348492660222), + ('ASP10000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',2.69581191222571), + ('ASP12000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',4.1862917611489), + ('ASP16000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',9.09797526283241), + ('ASP06000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',0.852601662887377), + ('ASP08000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',1.4348492660222), + ('ASP10000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',2.69581191222571), + ('ASP12000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',4.1862917611489), + ('ASP16000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',9.09797526283241), + ('ASP06000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',0.852601662887377), + ('ASP08000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',1.4348492660222), + ('ASP10000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',2.69581191222571), + ('ASP12000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',4.1862917611489), + ('ASP16000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',9.09797526283241), + ('ASP06000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',0.852601662887377), + ('ASP08000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',1.4348492660222), + ('ASP10000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',2.69581191222571), + ('ASP12000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',4.1862917611489), + ('ASP16000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',9.09797526283241), + ('ARP06000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',0.70132159315339), + ('ARP08000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',1.16639446371434), + ('ARP10000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',2.06032580911152), + ('ARP12000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',3.3063246409675), + ('ARP16000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',7.29303859560353), + ('ARP06000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',0.70132159315339), + ('ARP08000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',1.16639446371434), + ('ARP10000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',2.06032580911152), + ('ARP12000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',3.3063246409675), + ('ARP16000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',7.29303859560353), + ('ARP06000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',0.70132159315339), + ('ARP08000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',1.16639446371434), + ('ARP10000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',2.06032580911152), + ('ARP12000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',3.3063246409675), + ('ARP16000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',7.29303859560353), + ('ARP06000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',0.70132159315339), + ('ARP08000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',1.16639446371434), + ('ARP10000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',2.06032580911152), + ('ARP12000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',3.3063246409675), + ('ARP16000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',7.29303859560353), + ('ANP12000A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ',7.09567010761259), + ('ANP15000A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ',10.3452077597572), + ('ANP17500A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ',14.4071298249379), + ('CAS12000P26','Cascade Tall Square Planter - Black Onyx','SAA14001A10C006LRCDJ',6.29314316635745), + ('CAS15000P26','Cascade Tall Square Planter - Black Onyx','SAA14001A10C006LRCDJ',15.3787074829932), + ('CAS12000P80','Cascade Tall Square Planter - Glossy White','SAA14001A10C006LRCDJ',6.29314316635745), + ('CAS15000P80','Cascade Tall Square Planter - Glossy White','SAA14001A10C006LRCDJ',15.3787074829932), + ('CAR12000P26','Cascade Tall Round Planter - Black Onyx','SAA14001A10C006LRCDJ',8.71982072275551), + ('CAR15000P26','Cascade Tall Round Planter - Black Onyx','SAA14001A10C006LRCDJ',15.8462292221236), + ('CAR12000P80','Cascade Tall Round Planter - Glossy White','SAA14001A10C006LRCDJ',8.71982072275551), + ('CAR15000P80','Cascade Tall Round Planter - Glossy White','SAA14001A10C006LRCDJ',15.8462292221236), + ('SKR12000G27','Santa Fe Round Planter - Black Sand','SAA14001A10C006LRCDJ',4.42057974300831), + ('SKR16000G27','Santa Fe Round Planter - Black Sand','SAA14001A10C006LRCDJ',9.79167124866476), + ('SKR12000E66','Santa Fe Round Planter - Cavern Clay','SAA14001A10C006LRCDJ',4.42057974300831), + ('SKR16000E66','Santa Fe Round Planter - Cavern Clay','SAA14001A10C006LRCDJ',9.79167124866476), + ('SKR12000A56','Santa Fe Round Planter - Pebble Gray','SAA14001A10C006LRCDJ',4.42057974300831), + ('SKR16000A56','Santa Fe Round Planter - Pebble Gray','SAA14001A10C006LRCDJ',9.79167124866476), + ('SKS12000G27','Santa Fe Square Planter - Black Sand','SAA14001A10C006LRCDJ',5.54815910808768), + ('SKS16000G27','Santa Fe Square Planter - Black Sand','SAA14001A10C006LRCDJ',10.8425160791589), + ('SKS12000E66','Santa Fe Square Planter - Cavern Clay','SAA14001A10C006LRCDJ',5.54815910808768), + ('SKS16000E66','Santa Fe Square Planter - Cavern Clay','SAA14001A10C006LRCDJ',10.8425160791589), + ('SKS12000A56','Santa Fe Square Planter - Pebble Gray','SAA14001A10C006LRCDJ',5.54815910808768), + ('SKS16000A56','Santa Fe Square Planter - Pebble Gray','SAA14001A10C006LRCDJ',10.8425160791589), + ('WBP16000P82','Whiskey Barrel Planter - Aged Oak','SAA14001A10C006LRCDJ',4.5) + ) x("target","descr","clone","cost") ) ,istka AS ( INSERT INTO lgdat.stka @@ -878,7 +877,7 @@ repl AS ( ,cgburv ,cgtptd ,cgsdat - ,cgstcs + ,cost cgstcs ,cgaccs ,cgavcs ,cgstoc @@ -930,7 +929,7 @@ repl AS ( ,chscr ,chlcr ,chsdat - ,chstcs + ,cost chstcs ,chaccs ,chavcs ,chsdr @@ -976,7 +975,7 @@ repl AS ( SELECT target y0part ,y0plnt - ,y0stcs + ,cost y0stcs ,y0accs ,y0avcs ,y0suc From 7008f57f668153768758164cb2c87641d5f6ce87 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 16 Apr 2019 13:26:39 +0000 Subject: [PATCH 2/9] make sure days are between 1 and 28 --- route_sql/addmonth_vd.sql | 4 ++-- route_sql/addmonth_vupd.sql | 2 +- route_sql/new_basket.sql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/route_sql/addmonth_vd.sql b/route_sql/addmonth_vd.sql index 5c8b2d6..4abab76 100644 --- a/route_sql/addmonth_vd.sql +++ b/route_sql/addmonth_vd.sql @@ -174,7 +174,7 @@ target AS (select target_increment incr) _month ,seq ,promo - ,round((dom_wa/value_usd)::numeric,0)::int odom + ,greatest(least(round((dom_wa/value_usd)::numeric,0)::int,28),1) odom ,round((rlag_wa/value_usd)::numeric,0)::int rlag ,round((slag_wa/value_usd)::numeric,0)::int slag ,value_usd/sum(value_usd) over (partition by _month) momix @@ -575,4 +575,4 @@ GROUP BY ,version ,iter ) -SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file +SELECT json_agg(row_to_json(insagg)) x from insagg diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index 88fb2b9..fb9e9fa 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -169,7 +169,7 @@ target AS (select target_volume vincr, target_price pincr) _month ,seq ,promo - ,round((dom_wa/value_usd)::numeric,0)::int odom + ,greatest(least(round((dom_wa/value_usd)::numeric,0)::int,28),1) odom ,round((rlag_wa/value_usd)::numeric,0)::int rlag ,round((slag_wa/value_usd)::numeric,0)::int slag ,value_usd/sum(value_usd) over (partition by _month) momix diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index c4ed2f7..945ec1c 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -247,7 +247,7 @@ target AS (select $$replace_request$$::json def) _month ,seq ,promo - ,round((dom_wa/value_usd)::numeric,0)::int odom + ,greatest(least(round((dom_wa/value_usd)::numeric,0)::int,28),1) odom ,round((rlag_wa/value_usd)::numeric,0)::int rlag ,round((slag_wa/value_usd)::numeric,0)::int slag ,value_usd/sum(value_usd) over (partition by _month) momix From f71fee5df6662b9f11c8b02230278e846242678f Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 16 Apr 2019 09:18:37 -0500 Subject: [PATCH 3/9] add last change --- route_sql/build/rep_totals.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/route_sql/build/rep_totals.sql b/route_sql/build/rep_totals.sql index f0846db..dde3617 100644 --- a/route_sql/build/rep_totals.sql +++ b/route_sql/build/rep_totals.sql @@ -33,6 +33,7 @@ SELECT ,to_char(sum(sales_adj),'999,999,999') sales_adj ,to_char(sum(sales_adj - scogs_adj),'999,999,999') margin_adj ,count(iterdef) "# of changes" + ,(max(iterdef->>'stamp'))::timestamptz "last edit" FROM preagg GROUP BY From 9829d643680843b7909d4f8ea2b015873217fd3b Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 16 Apr 2019 18:08:24 -0400 Subject: [PATCH 4/9] swap part number and associated masterd data --- route_sql/build/set_part_master.sql | 332 ++++++++++++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 route_sql/build/set_part_master.sql diff --git a/route_sql/build/set_part_master.sql b/route_sql/build/set_part_master.sql new file mode 100644 index 0000000..fab9be4 --- /dev/null +++ b/route_sql/build/set_part_master.sql @@ -0,0 +1,332 @@ +BEGIN; + +WITH +repl AS ( + SELECT * FROM + ( + VALUES + ('IFA06000G181012LRCIR ','IFA06000G181012LRCIR') + ) as x(orig,fix) +) +,SEG AS ( + SELECT + x.GLEC + ,x.SEGM + FROM + ( + VALUES + ('1CU','Retail'), + ('1GR','Greenhouse'), + ('1NU','Nursery'), + ('1RE','Retail'), + ('2WI','Greenhouse'), + ('3BM','Other'), + ('3CO','Other'), + ('3PE','Other'), + ('3PP','Other'), + ('4CO','Other'), + ('4RA','Other'), + ('9MI','Other'), + ('9SA','Other'), + ('9TO','Other') + ) X(GLEC, SEGM) +) +,MG AS ( + SELECT + X.F1, X.MING, X.GRP + FROM + ( + VALUES + ('L','000','Branded'), + ('L','B10','Branded'), + ('L','B11','Branded'), + ('L','B52','Branded'), + ('L','C10','Branded'), + ('L','D12','Branded'), + ('L','M11','Branded'), + ('L','P12','Branded'), + ('L','P13','Branded'), + ('L','S10','Branded'), + ('L','Y10','Branded'), + ('L','Y11','Branded'), + ('L','Y12','Branded'), + ('P','B10','Branded'), + ('P','B11','Branded'), + ('P','B52','Branded') + ) AS X (F1, MING, GRP) +) +,REPC AS ( + SELECT + LTRIM(RTRIM(C.A9)) RCODE + ,LTRIM(RTRIM(C.A9)) || ' - ' || C.A30 REPP + ,COALESCE(Q.DIR,'Other') DIRECTOR + FROM + LGDAT.CODE C + LEFT OUTER JOIN RLARP.QRH Q ON + Q.QR = LTRIM(RTRIM(C.A9)) + WHERE + C.A2 = 'MM' +) +--MOLD DESCRIPTIONS +,MD AS ( + SELECT + U.MOLD + ,MAX(U.DESCR) DESCR + FROM + ( + SELECT + SUBSTR(M.AVPART,1,8) MOLD + ,MAX(M.AVDES1) DESCR + FROM + LGDAT.STKMM M + WHERE + LENGTH(M.AVPART) > 8 + AND SUBSTR(M.AVGLED,1,1) <= '2' + GROUP BY + SUBSTR(M.AVPART,1,8) + UNION ALL + SELECT + SUBSTR(P.AWPART,1,8) MOLD + ,MAX(P.AWDES1) DESCR + FROM + LGDAT.STKMP P + WHERE + LENGTH(P.AWPART) > 8 + AND SUBSTR(P.AWGLED,1,1) <= '2' + GROUP BY + SUBSTR(P.AWPART,1,8) + ) U + GROUP BY + U.MOLD +) +----------------------------------------------------sales major codes---------------------------------------------------------------------------------------------------------------------------------- +,SJ AS ( + SELECT * FROM LGDAT.MMSL WHERE COALESCE(BSMNCD,'') = '' +) +----------------------------------------------------sales minor codes---------------------------------------------------------------------------------------------------------------------------------- +,SI AS ( + SELECT * FROM LGDAT.MMSL WHERE COALESCE(BSMNCD,'') <> '' +) +,copr AS ( + SELECT + LTRIM(RTRIM(A9)) AS COMP, + A30 AS DESCR, + SUBSTR(C.A249,242,2) CURR, + SUBSTR(C.A249,32,4) AS GL, + SUBSTR(C.A249,190,4) AS AR, + SUBSTR(C.A249,182,4) AS AP, + SUBSTR(C.A249,198,4) AS FA, + SUBSTR(C.A249,238,4) AS IC , + SUBSTR(D.A249,9,5) CONS_FUNC + FROM + LGDAT.CODE + LEFT OUTER JOIN LGDAT.NAME C ON + 'C0000'||LTRIM(RTRIM(A9)) = C.A7 + LEFT OUTER JOIN LGDAT.NAME D ON + 'D0000'||LTRIM(RTRIM(A9)) = D.A7 + WHERE + A2 = 'AA' OR A2 IS NULL +) +,x AS ( +SELECT + o.part origpart + ,repl.fix as part + ,COALESCE(m.avdplt,p.awdplt) plnt + ,COALESCE(m.avglcd, p.awgldc) ord_gldc + ,COALESCE(m.avmajg,p.awmajg) majg + ,COALESCE(m.avming,p.awming) ming + ,COALESCE(m.avmajs,p.awmajs) majs + ,COALESCE(m.avmins,p.awmins) mins + ,COALESCE(m.avglcd,p.awgldc) gldc + ,COALESCE(m.avgled,p.awgled) glec + ,COALESCE(m.avharm,p.awharm) harm + ,COALESCE(m.avclss,p.awclss) clss + ,SUBSTR(COALESCE(m."avcpt#",p."awvpt#"),1,1) brand + ,COALESCE(m.avassc,p.awassc) assc + ,COALESCE(cm.cgstcs, cp.chstcs, cr.y0stcs) stdcost + ,copr.curr c_currency + ,cx.rate c_rate + ,SUBSTR(o.part,1,3)||coalesce(' - '||F.DESCR,'') part_family + ,SUBSTRING(o.part,1,8)||coalesce(' - '||MD.DESCR,'') part_group + ,COALESCE(MG.GRP,'Unbranded') branding + ,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(o.part,9,3) ELSE '' END color + ,COALESCE(SEG.SEGM,'Other') segm + ,COALESCE(m.avmajg,p.awmajg)||COALESCE(' - '||BQDES,'') majg_descr + ,COALESCE(m.avming,p.awming)||COALESCE(' - '||BRDES,'') ming_descr + ,COALESCE(m.avmajs,p.awmajs)||COALESCE(' - '||SJ.BSDES1,'') majs_descr + ,COALESCE(m.avmins,p.awmins)||COALESCE(' - '||SI.BSDES1,'') mins_descr + --quota rep-------------------------------------------- + ,RTRIM( + COALESCE( + --retail items go to currep, or if null go to 90005 + CASE WHEN COALESCE(m.avgled,p.awgled) IN ('1RE','1CU') THEN + CASE WHEN bc.bvctry = 'CAN' THEN + --Rachel Bowman + '50300' + ELSE + --retail chain got to Mark Wilkinson + CASE COALESCE(cg.cgrp,bc.bvname) + WHEN 'THE HOME DEPOT' THEN '90005' + WHEN 'DO IT BEST' THEN '90005' + WHEN 'ACE HARDWARE' THEN '90005' + WHEN 'ALDI' THEN '90005' + WHEN 'AMAZON.COM' THEN '90005' + WHEN 'GARDEN RIDGE CORP' THEN '90005' + --all other retail goes to Doran Marable + ELSE '50200' + END + END + ELSE + CASE WHEN COALESCE(m.avming,p.awming) = 'B52' THEN + 'PW' + --gdir, ndir go to bill-to rep + ELSE + CASE WHEN bc.bvclas IN ('GDIR','NDIR') THEN + bc.bvsalm + ELSE + sc.bvsalm + END + END + END + ,'' + ) + ) quota_rep + ,repc.repp quota_rep_descr + ,repc.director director_descr +FROM + repl + INNER JOIN rlarp.osm_fcpool o ON + o.part = repl.orig + LEFT OUTER JOIN lgdat.stkmm m ON + m.avpart = repl.fix + LEFT OUTER JOIN lgdat.stkmp p ON + p.awpart = repl.fix + LEFT OUTER JOIN lgdat.stka a ON + a.v6part = repl.fix + AND a.v6plnt = COALESCE(m.avdplt,p.awdplt) + LEFT OUTER JOIN lgdat.icstm cm ON + cm.cgpart = repl.fix + AND cm.cgplnt = COALESCE(m.avdplt,p.awdplt) + LEFT OUTER JOIN lgdat.icstp cp ON + cp.chpart = repl.fix + AND cp.chplnt = COALESCE(m.avdplt,p.awdplt) + LEFT OUTER JOIN lgdat.icstr cr ON + cr.y0part = repl.fix + AND cr.y0plnt = COALESCE(m.avdplt,p.awdplt) + LEFT OUTER JOIN SEG ON + SEG.GLEC = COALESCE(m.avgled,p.awgled) + --AND SEG.SEGM <> 'Other' + LEFT OUTER JOIN MG ON + MG.F1 = SUBSTR(o.part,16,1) + AND MG.MING = COALESCE(m.avming,p.awming) + LEFT OUTER JOIN rlarp.family F ON + F.F3 = SUBSTR(o.part,1,3) + LEFT OUTER JOIN MD ON + MD.MOLD = SUBSTR(o.part,1,8) + LEFT OUTER JOIN SI ON + SI.BSMJCD = COALESCE(m.avmajs,p.awmajs) + AND SI.BSMNCD = COALESCE(m.avmins,p.awmins) + LEFT OUTER JOIN SJ ON + SJ.BSMJCD = COALESCE(m.avmajs,p.awmajs) + LEFT OUTER JOIN LGDAT.MAJG ON + BQGRP = COALESCE(m.avmajg,p.awmajg) + LEFT OUTER JOIN LGDAT.MMGP ON + BRMGRP = COALESCE(m.avming,p.awming) + AND BRGRP = COALESCE(m.avmajg,p.awmajg) + LEFT OUTER JOIN lgdat.plnt ON + yaplnt = a.v6plnt + LEFT OUTER JOIN copr ON + copr.comp = yacomp::text + LEFT OUTER JOIN rlarp.ffcret cx ON + cx.perd = '1910' + AND cx.rtyp = 'MA' + AND cx.fcur = copr.curr + AND cx.tcur = 'US' + ------for quota rep------------ + LEFT OUTER JOIN LGDAT.CUST BC ON + BC.BVCUST = o.BILL_CUST + LEFT OUTER JOIN LGDAT.CUST SC ON + SC.BVCUST = o.SHIP_CUST + LEFT OUTER JOIN RLARP.FFCUST CG ON + CG.CUSTN = BC.BVCUST + LEFT OUTER JOIN RLARP.FFCUST SG ON + SG.CUSTN = SC.BVCUST + LEFT OUTER JOIN REPC ON + REPC.RCODE = RTRIM( + COALESCE( + --retail items go to currep, or if null go to 90005 + CASE WHEN COALESCE(m.avgled,p.awgled) IN ('1RE','1CU') THEN + CASE WHEN bc.bvctry = 'CAN' THEN + --Rachel Bowman + '50300' + ELSE + --retail chain got to Mark Wilkinson + CASE COALESCE(cg.cgrp,bc.bvname) + WHEN 'THE HOME DEPOT' THEN '90005' + WHEN 'DO IT BEST' THEN '90005' + WHEN 'ACE HARDWARE' THEN '90005' + WHEN 'ALDI' THEN '90005' + WHEN 'AMAZON.COM' THEN '90005' + WHEN 'GARDEN RIDGE CORP' THEN '90005' + --all other retail goes to Doran Marable + ELSE '50200' + END + END + ELSE + CASE WHEN COALESCE(m.avming,p.awming) = 'B52' THEN + 'PW' + --gdir, ndir go to bill-to rep + ELSE + CASE WHEN bc.bvclas IN ('GDIR','NDIR') THEN + bc.bvsalm + ELSE + sc.bvsalm + END + END + END + ,'' + ) + ) +) +,u AS ( +UPDATE + rlarp.osm_fcpool o +SET + part = x.part + ,plnt = x.plnt + ,ord_gldc = x.ord_gldc + ,majg = x.majg + ,ming = x.ming + ,majs = x.majs + ,mins = x.mins + ,gldc = x.gldc + ,glec = x.glec + ,harm = x.harm + ,clss = x.clss + ,assc = x.assc + ,brand = x.brand + ,fb_cst_loc = o.fb_qty * x.stdcost + ,fb_cst_loc_cur = o.fb_qty * x.stdcost + ,fb_cst_loc_fut = o.fb_qty * x.stdcost + ,part_family = x.part_family + ,part_group = x.part_group + ,branding = x.branding + ,color = x.color + ,segm = x.color + ,majg_descr = x.majg_descr + ,ming_descr = x.majg_descr + ,majs_descr = x.majs_descr + ,mins_descr = x.mins_descr + ,quota_rep = x.quota_rep + ,quota_rep_descr = x.quota_rep_descr + ,director_descr = x.director_descr +FROM + x +WHERE + x.origpart = o.part +RETURNING o.* +) +SELECT * FROM u; + +--ROLLBACK; +COMMIT; \ No newline at end of file From 8525e9c12a7c2337b118fb0f31730889d13b0024 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 16 Apr 2019 18:08:45 -0400 Subject: [PATCH 5/9] rep query --- route_sql/build/set_quota_rep.sql | 112 ++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 route_sql/build/set_quota_rep.sql diff --git a/route_sql/build/set_quota_rep.sql b/route_sql/build/set_quota_rep.sql new file mode 100644 index 0000000..007e240 --- /dev/null +++ b/route_sql/build/set_quota_rep.sql @@ -0,0 +1,112 @@ +With +REPC AS ( + SELECT + LTRIM(RTRIM(C.A9)) RCODE + ,LTRIM(RTRIM(C.A9)) || ' - ' || C.A30 REPP + ,COALESCE(Q.DIR,'Other') DIRECTOR + FROM + LGDAT.CODE C + LEFT OUTER JOIN RLARP.QRH Q ON + Q.QR = LTRIM(RTRIM(C.A9)) + WHERE + C.A2 = 'MM' +) +,r AS ( +SELECT + b.quota_rep base_rep + --quota rep-------------------------------------------- + ,RTRIM( + COALESCE( + --retail items go to currep, or if null go to 90005 + CASE WHEN COALESCE(b.glec) IN ('1RE','1CU') THEN + CASE WHEN bc.bvctry = 'CAN' THEN + --Rachel Bowman + '50300' + ELSE + --retail chain got to Mark Wilkinson + CASE COALESCE(cg.cgrp,bc.bvname) + WHEN 'THE HOME DEPOT' THEN '90005' + WHEN 'DO IT BEST' THEN '90005' + WHEN 'ACE HARDWARE' THEN '90005' + WHEN 'ALDI' THEN '90005' + WHEN 'AMAZON.COM' THEN '90005' + WHEN 'GARDEN RIDGE CORP' THEN '90005' + --all other retail goes to Doran Marable + ELSE '50200' + END + END + ELSE + CASE WHEN COALESCE(b.ming) = 'B52' THEN + 'PW' + --gdir, ndir go to bill-to rep + ELSE + CASE WHEN bc.bvclas IN ('GDIR','NDIR') THEN + bc.bvsalm + ELSE + sc.bvsalm + END + END + END + ,'' + ) + ) revised_rep + ,sum(fb_val_loc * r_rate) sales +FROM + rlarp.osm_fcpool b + LEFT OUTER JOIN LGDAT.CUST BC ON + BC.BVCUST = b.BILL_CUST + LEFT OUTER JOIN LGDAT.CUST SC ON + SC.BVCUST = b.SHIP_CUST + LEFT OUTER JOIN RLARP.FFCUST CG ON + CG.CUSTN = BC.BVCUST + LEFT OUTER JOIN RLARP.FFCUST SG ON + SG.CUSTN = SC.BVCUST +GROUP BY + b.quota_rep + --quota rep-------------------------------------------- + ,RTRIM( + COALESCE( + --retail items go to currep, or if null go to 90005 + CASE WHEN COALESCE(b.glec) IN ('1RE','1CU') THEN + CASE WHEN bc.bvctry = 'CAN' THEN + --Rachel Bowman + '50300' + ELSE + --retail chain got to Mark Wilkinson + CASE COALESCE(cg.cgrp,bc.bvname) + WHEN 'THE HOME DEPOT' THEN '90005' + WHEN 'DO IT BEST' THEN '90005' + WHEN 'ACE HARDWARE' THEN '90005' + WHEN 'ALDI' THEN '90005' + WHEN 'AMAZON.COM' THEN '90005' + WHEN 'GARDEN RIDGE CORP' THEN '90005' + --all other retail goes to Doran Marable + ELSE '50200' + END + END + ELSE + CASE WHEN COALESCE(b.ming) = 'B52' THEN + 'PW' + --gdir, ndir go to bill-to rep + ELSE + CASE WHEN bc.bvclas IN ('GDIR','NDIR') THEN + bc.bvsalm + ELSE + sc.bvsalm + END + END + END + ,'' + ) + ) +) +SELECT + b.repp + ,v.repp + ,r.sales +FROM + r + LEFT OUTER JOIN REPC b on + b.rcode = r.base_rep + LEFT OUTER JOIN REPC v on + v.rcode = r.revised_rep \ No newline at end of file From 82b0b10dfb88aef527f2b1d7d3b29584e414cc9c Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Tue, 16 Apr 2019 18:48:56 -0400 Subject: [PATCH 6/9] query no cost --- route_sql/build/test_cost.sql | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 route_sql/build/test_cost.sql diff --git a/route_sql/build/test_cost.sql b/route_sql/build/test_cost.sql new file mode 100644 index 0000000..158ee7e --- /dev/null +++ b/route_sql/build/test_cost.sql @@ -0,0 +1,40 @@ +WITH nc AS ( +select + part + ,plnt + , to_char(sum(fb_val_loc * r_rate),'9,999,999') sales + , to_char(sum(fb_qty),'9,999,999') units +from + rlarp.osm_fcpool +where + ( + + ( + fb_qty <> 0 + and coalesce(fb_cst_loc,0) = 0 + ) + or plnt is null + ) + and version = 'b20' +group by + part + ,plnt +) +SELECT + nc.* + ,v6stat + ,coalesce(cgstcs, chstcs,y0stcs) stcs +FROM + nc + left outer join lgdat.stka ON + v6part = part + and v6plnt = plnt + left outer join lgdat.icstm ON + cgpart = part + and cgplnt = plnt + left outer join lgdat.icstp ON + chpart = part + and chplnt = plnt + left outer join lgdat.icstr ON + y0part = part + and y0plnt = plnt From cd53505d59debef6b97e93c609bf6fca2d37db55 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 16 Apr 2019 18:50:01 -0400 Subject: [PATCH 7/9] use replacement part in all cases, and apply currency --- route_sql/build/set_part_master.sql | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/route_sql/build/set_part_master.sql b/route_sql/build/set_part_master.sql index fab9be4..4b9c07f 100644 --- a/route_sql/build/set_part_master.sql +++ b/route_sql/build/set_part_master.sql @@ -5,7 +5,7 @@ repl AS ( SELECT * FROM ( VALUES - ('IFA06000G181012LRCIR ','IFA06000G181012LRCIR') + ('MOW24000A47E880','MOW24000A47E880') ) as x(orig,fix) ) ,SEG AS ( @@ -146,10 +146,10 @@ SELECT ,COALESCE(cm.cgstcs, cp.chstcs, cr.y0stcs) stdcost ,copr.curr c_currency ,cx.rate c_rate - ,SUBSTR(o.part,1,3)||coalesce(' - '||F.DESCR,'') part_family - ,SUBSTRING(o.part,1,8)||coalesce(' - '||MD.DESCR,'') part_group + ,SUBSTR(repl.fix,1,3)||coalesce(' - '||F.DESCR,'') part_family + ,SUBSTRING(repl.fix,1,8)||coalesce(' - '||MD.DESCR,'') part_group ,COALESCE(MG.GRP,'Unbranded') branding - ,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(o.part,9,3) ELSE '' END color + ,CASE WHEN substring(COALESCE(m.avgled, p.awgled),1,1) <= '2' THEN SUBSTRING(repl.fix,9,3) ELSE '' END color ,COALESCE(SEG.SEGM,'Other') segm ,COALESCE(m.avmajg,p.awmajg)||COALESCE(' - '||BQDES,'') majg_descr ,COALESCE(m.avming,p.awming)||COALESCE(' - '||BRDES,'') ming_descr @@ -217,12 +217,12 @@ FROM SEG.GLEC = COALESCE(m.avgled,p.awgled) --AND SEG.SEGM <> 'Other' LEFT OUTER JOIN MG ON - MG.F1 = SUBSTR(o.part,16,1) + MG.F1 = SUBSTR(repl.fix,16,1) AND MG.MING = COALESCE(m.avming,p.awming) LEFT OUTER JOIN rlarp.family F ON - F.F3 = SUBSTR(o.part,1,3) + F.F3 = SUBSTR(repl.fix,1,3) LEFT OUTER JOIN MD ON - MD.MOLD = SUBSTR(o.part,1,8) + MD.MOLD = SUBSTR(repl.fix,1,8) LEFT OUTER JOIN SI ON SI.BSMJCD = COALESCE(m.avmajs,p.awmajs) AND SI.BSMNCD = COALESCE(m.avmins,p.awmins) @@ -308,6 +308,10 @@ SET ,fb_cst_loc = o.fb_qty * x.stdcost ,fb_cst_loc_cur = o.fb_qty * x.stdcost ,fb_cst_loc_fut = o.fb_qty * x.stdcost + ,cost_loc = o.fb_qty * x.stdcost + ,cost_usd = o.fb_qty * x.stdcost * x.c_rate + ,c_currency = x.c_currency + ,c_rate = x.c_rate ,part_family = x.part_family ,part_group = x.part_group ,branding = x.branding @@ -329,4 +333,4 @@ RETURNING o.* SELECT * FROM u; --ROLLBACK; -COMMIT; \ No newline at end of file +--COMMIT; \ No newline at end of file From 2fb28dd85fc1a6a1110abc1b4780c89682e002d0 Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Mon, 29 Apr 2019 11:33:12 -0400 Subject: [PATCH 8/9] update was assigning wrong columns --- route_sql/build/set_part_master.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/route_sql/build/set_part_master.sql b/route_sql/build/set_part_master.sql index 4b9c07f..aca6318 100644 --- a/route_sql/build/set_part_master.sql +++ b/route_sql/build/set_part_master.sql @@ -306,8 +306,8 @@ SET ,assc = x.assc ,brand = x.brand ,fb_cst_loc = o.fb_qty * x.stdcost - ,fb_cst_loc_cur = o.fb_qty * x.stdcost - ,fb_cst_loc_fut = o.fb_qty * x.stdcost + --,fb_cst_loc_cur = o.fb_qty * x.stdcost + --,fb_cst_loc_fut = o.fb_qty * x.stdcost ,cost_loc = o.fb_qty * x.stdcost ,cost_usd = o.fb_qty * x.stdcost * x.c_rate ,c_currency = x.c_currency @@ -316,9 +316,9 @@ SET ,part_group = x.part_group ,branding = x.branding ,color = x.color - ,segm = x.color + ,segm = x.segm ,majg_descr = x.majg_descr - ,ming_descr = x.majg_descr + ,ming_descr = x.ming_descr ,majs_descr = x.majs_descr ,mins_descr = x.mins_descr ,quota_rep = x.quota_rep From 031d2d4ae8c978771550ccd126fdf2716523d127 Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Tue, 30 Apr 2019 15:43:50 -0400 Subject: [PATCH 9/9] get rid of space --- route_sql/build/test_cost.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/route_sql/build/test_cost.sql b/route_sql/build/test_cost.sql index 158ee7e..581c661 100644 --- a/route_sql/build/test_cost.sql +++ b/route_sql/build/test_cost.sql @@ -8,7 +8,6 @@ from rlarp.osm_fcpool where ( - ( fb_qty <> 0 and coalesce(fb_cst_loc,0) = 0