From f764bc4c31606520908963a8adf53a687d31b2fd Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 2 Apr 2020 10:06:22 -0400 Subject: [PATCH] swap fake parts --- build/swap_fake_parts.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 build/swap_fake_parts.sql diff --git a/build/swap_fake_parts.sql b/build/swap_fake_parts.sql new file mode 100644 index 0000000..32b0073 --- /dev/null +++ b/build/swap_fake_parts.sql @@ -0,0 +1,26 @@ +with +fp as ( + SELECT + od.part, + sum(fb_val_loc * r_rate) sales, + sum(fb_cst_loc * c_rate) scost + FROM + rlarp.osmf_dev od + LEFT OUTER JOIN rlarp.itemmv m ON + m.item = od.part + WHERE + m.item is null + GROUP BY + od.part +) +SELECT + fp.part, + min(item) item +FROM + fp + LEFT OUTER JOIN rlarp.itemmv m ON + substring(m.item,1,11) = fp.part +GROUP BY + fp.part +ORDER BY + fp.part \ No newline at end of file