Compare commits

..

No commits in common. "55dcb65a171494727f4b92ade9f5d0cffbb59174" and "5134b659c094304db2459b5cfdae289aec2b842e" have entirely different histories.

2 changed files with 7 additions and 28 deletions

View File

@ -8,10 +8,16 @@ baseline AS (
,'actuals' iter
FROM
rlarp.osm_dev o
--snap the ship dates of the historic fiscal period
LEFT OUTER JOIN gld ON
gld.fspr = o.fspr
--get the shipping season for open orders based on the snapped date
LEFT OUTER JOIN gld ss ON
greatest(least(o.sdate,gld.edat),gld.sdat) BETWEEN ss.sdat AND ss.edat
WHERE
(
--base period orders booked....
[order_field_name] BETWEEN [target_odate_from] AND [target_odate_to]
[target_odate] BETWEEN [target_odate_from] AND [target_odate_to]
--...or any open orders currently booked before cutoff....
OR ([status_flag] IN ([status_list]) and [target_date] <= [target_date_from])
--...or anything that shipped in that period

View File

@ -1,27 +0,0 @@
DO
$$
DECLARE
clist text;
BEGIN
-------------------------------build a column list----------------------------------------
SELECT
string_agg(
format('%I',cname) || CASE WHEN func IN ('odate','sdate') THEN ' + interval ''1 year''' ELSE '' END,E'\n,' ORDER BY opos ASC)
INTO
clist
FROM
fc.target_meta
WHERE
func NOT IN ('version');
RAISE NOTICE 'build list: %',clist;
CREATE TEMP TABLE sql(t text);
INSERT INTO sql SELECT clist;
END
$$;
select * from sql;