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