diff --git a/inquirey/mix.pg.sql b/inquirey/mix.pg.sql new file mode 100644 index 0000000..3aa7b90 --- /dev/null +++ b/inquirey/mix.pg.sql @@ -0,0 +1,103 @@ +SELECT + o.fspr + ,o.plnt + ,o.promo + ,o.terms + ,o.bill_cust_descr + ,o.ship_cust_descr + ,o.dsm + ,o.quota_rep_descr + ,o.director + ,o.billto_group + ,o.shipto_group + ,o.chan + ,o.chansub + ,o.chan_retail + ,o.part + ,o.part_descr + ,o.part_group + ,o.branding + ,o.majg_descr + ,o.ming_descr + ,o.majs_descr + ,o.mins_descr + ,o.segm + ,o.substance + ,o.fs_line + ,o.r_currency + ,o.r_rate + ,o.c_currency + ,o.c_rate + ,0::numeric units + ,(c.price_choice * sum(o.units) - sum(value_usd))/o.r_rate value_loc + ,c.price_choice * sum(o.units) - sum(value_usd) value_usd + ,0::numeric cost_loc + ,0::numeric cost_usd + ,o.calc_status + ,o.flag + ,o.order_date + ,o.order_month + ,o.order_season + ,o.request_date + ,o.request_month + ,o.request_season + ,o.ship_date + ,o.ship_month + ,o.ship_season + ,o.version + ,'Pricing 2' iter + ,pounds +FROM + rlarp.osm_pool o + -- CROSS JOIN logload + INNER JOIN choose c ON + c.billto_group = o.billto_group + AND c.shipto_group = o.shipto_group + -- AND substring(c.dsm,1,5) = substring(o.dsm,1,5) + AND c.part = o.part + AND c.order_date = o.order_date +WHERE + o.order_season = 2026 +GROUP BY + o.fspr + ,o.plnt + ,o.promo + ,o.terms + ,o.bill_cust_descr + ,o.ship_cust_descr + ,o.dsm + ,o.quota_rep_descr + ,o.director + ,o.billto_group + ,o.shipto_group + ,o.chan + ,o.chansub + ,o.chan_retail + ,o.part + ,o.part_descr + ,o.part_group + ,o.branding + ,o.majg_descr + ,o.ming_descr + ,o.majs_descr + ,o.mins_descr + ,o.segm + ,o.substance + ,o.fs_line + ,o.r_currency + ,o.r_rate + ,o.c_currency + ,o.c_rate + ,c.price_choice + ,o.calc_status + ,o.flag + ,o.order_date + ,o.order_month + ,o.order_season + ,o.request_date + ,o.request_month + ,o.request_season + ,o.ship_date + ,o.ship_month + ,o.ship_season + ,o.version