diff --git a/routes/baseline/gen_baseline.sql b/routes/baseline/gen_baseline.sql index fcb5aa1..46d030d 100644 --- a/routes/baseline/gen_baseline.sql +++ b/routes/baseline/gen_baseline.sql @@ -49,8 +49,6 @@ WHERE dtype = 'date' AND fkey IS NOT NULL; -CREATE TABLE IF NOT EXISTS fc.sql(cmd text PRIMARY KEY, t text ); - -------------------------------build a column list----------------------------------------- SELECT string_agg('o.'||format('%I',cname),E'\n ,' ORDER BY opos ASC) @@ -107,11 +105,11 @@ FROM WHERE ( --base period orders booked.... - $$||_order_date||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date + $$||format('%I',_order_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date --...or any open orders currently booked before cutoff.... - OR ($$||_order_status||$$ IN (app_openstatus_code) and $$||_order_date||$$ <= 'app_openorder_cutoff'::date) + OR ($$||format('%I',_order_status)||$$ IN ('app_openstatus_code') and $$||format('%I',_order_date)||$$ <= 'app_openorder_cutoff'::date) --...or anything that shipped in that period - OR ($$||_ship_date||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date) + OR ($$||format('%I',_ship_date)||$$ BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date) ) --be sure to pre-exclude unwanted items, like canceled orders, non-gross sales, and short-ships $$::text