This commit is contained in:
Paul Trowbridge 2020-10-27 23:47:21 -04:00
parent 975ea43b65
commit 11a8ff2c68
2 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@ the basic assumption is a single sales table is available to work with that has
the goal then is to break that back apart to whatever degree is necessary. the goal then is to break that back apart to whatever degree is necessary.
* _**run**_ `schema.sql` and `perd.sql` to setup basic tables * _**run**_ `schema.sql` and `perd.sql` to setup basic tables
* create a table fc.live as copied from target * create a table fc.live as copied from target (will need to have columns `version` and `iter` added if not existing)
* _**run**_ `target_info.sql` to populate the `fc.target_meta` table that holds all the columns and their roles * _**run**_ `target_info.sql` to populate the `fc.target_meta` table that holds all the columns and their roles
* fill in flags on table `fc.target_meta` to show how the data is related * fill in flags on table `fc.target_meta` to show how the data is related
* _**run**_ `build_master_tables.sql` to generate foreign key based master data * _**run**_ `build_master_tables.sql` to generate foreign key based master data
@ -16,3 +16,4 @@ baseline
---------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------
* copy history and increment by year to form a baseline * copy history and increment by year to form a baseline
* need to be able to handle order/ship dates generically * need to be able to handle order/ship dates generically
* need to build the baseline sql

View File

@ -3,6 +3,7 @@ WITH
baseline AS ( baseline AS (
-----------------------copy YTD sales--------------------------------------------------------------------- -----------------------copy YTD sales---------------------------------------------------------------------
SELECT SELECT
[nonversion]
,'baseline' "version" ,'baseline' "version"
,'actuals' iter ,'actuals' iter
FROM FROM
@ -26,6 +27,7 @@ baseline AS (
UNION ALL UNION ALL
---------option 1: fill in the rest of the year, with the prior years sales-sales---------------------------- ---------option 1: fill in the rest of the year, with the prior years sales-sales----------------------------
SELECT SELECT
[nonversion]
,'baseline' "version" ,'baseline' "version"
,'plug' iter ,'plug' iter
FROM FROM
@ -40,6 +42,7 @@ baseline AS (
UNION ALL UNION ALL
--------option 2: fill in the remainder of the current year with current forecase----------------------------- --------option 2: fill in the remainder of the current year with current forecase-----------------------------
SELECT SELECT
[nonversion]
,'baseline' "version" ,'baseline' "version"
,'plug' iter ,'plug' iter
FROM FROM
@ -54,7 +57,8 @@ baseline AS (
) )
-------------------copy the baseline just generated and increment all the dates by one year------------------------------------ -------------------copy the baseline just generated and increment all the dates by one year------------------------------------
,incr AS ( ,incr AS (
SELECT SELECT
[nondate_columns]
,o.dcodat + interval '1 year' --incremented ,o.dcodat + interval '1 year' --incremented
,o.ddqdat + interval '1 year' --incremented ,o.ddqdat + interval '1 year' --incremented
,o.dhidat + interval '1 year' --incremented ,o.dhidat + interval '1 year' --incremented