get rid of sql table creation here, all column references should be formatted as quote itentifieds format('%I)
This commit is contained in:
parent
d1371bcdce
commit
53523eb330
@ -49,8 +49,6 @@ WHERE
|
|||||||
dtype = 'date'
|
dtype = 'date'
|
||||||
AND fkey IS NOT NULL;
|
AND fkey IS NOT NULL;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS fc.sql(cmd text PRIMARY KEY, t text );
|
|
||||||
|
|
||||||
-------------------------------build a column list-----------------------------------------
|
-------------------------------build a column list-----------------------------------------
|
||||||
SELECT
|
SELECT
|
||||||
string_agg('o.'||format('%I',cname),E'\n ,' ORDER BY opos ASC)
|
string_agg('o.'||format('%I',cname),E'\n ,' ORDER BY opos ASC)
|
||||||
@ -107,11 +105,11 @@ FROM
|
|||||||
WHERE
|
WHERE
|
||||||
(
|
(
|
||||||
--base period orders booked....
|
--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 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 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
|
--be sure to pre-exclude unwanted items, like canceled orders, non-gross sales, and short-ships
|
||||||
$$::text
|
$$::text
|
||||||
|
Loading…
Reference in New Issue
Block a user