Dimension tables – dim.customers
Resources
SQL to create and populate dim.customers
CREATE TABLE superstore.dim.customers(
customerid VARCHAR(25) PRIMARY KEY
,customername VARCHAR(50) NOT NULL
,currentpostalcode VARCHAR(12) NOT NULL
)
;
INSERT INTO superstore.dim.customers
SELECT DISTINCT customerid
,customername
,FIRST_VALUE(postalcode) OVER(
PARTITION BY customerid
ORDER BY rowid DESC
) AS currentpostalcode
FROM superstore.staging.orderitems
