“Creating a Staging Table for Skeleton Candy Sales Data from 2017-2019 using SQL”

Use SQL. 
–Skeleton Candy Part 1 – extract from 2017, 2018, 2019 tables and put into stagingTable
–Students, see notes below where it says –you need to fill this in here
–Create the staging table
DROP TABLE IF EXISTS stagingTable;
CREATE TABLE stagingTable (
yearInt INT(4),
monthInt INT(2),
–there will be more you need to fill in here
);
–Insert 2017 Data
INSERT INTO stagingTable(“monthInt”, “state”, “country”, “region”, “Product_Name”, “unitPrice” –you need to fill this in here)
SELECT “Month”, “State”, “Country”, “Region”, “Product”, “Per-Unit_price”, “Quantity”, “Order_Total” FROM pd2017
;
UPDATE stagingTable SET yearInt=2017;
–Insert 2018 Data
INSERT INTO stagingTable( — you need to fill this in here –)
SELECT … FROM pd2018
;
UPDATE stagingTable SET yearInt=2018 WHERE yearInt ISNULL;
–Insert 2019 Data
INSERT INTO stagingTable(– you need to fill this in here –)
SELECT … FROM pd2019
;
UPDATE stagingTable ( — you need to fill this in here );
SELECT * FROM stagingTable;
That is the ·     
Candy_part_1_skeleton_for_students.SQL

Comments

Leave a Reply