You are on page 1of 1

INSERT INTO stg_2_sales_fact(

order_id, order_date, customer_id_pk, category_id_pk,


product_id_pk, ship_id_pk, location_id_pk, sales,
quantity, discount, profit)

select distinct

stg.order_id, stg.order_date, c.customer_id_pk,


ca.category_id_pk ,
p.product_id_pk, s.ship_id_pk, l.location_id_pk, stg.sales,
stg.quantity, stg.discount, stg.profit

from STG_1 as stg


inner join stg_2_customer_dim as c
on stg.customer_id=c.customer_id_pk
inner join stg_2_category_dim as ca
on stg.sub_category=ca.sub_category
inner join stg_2_product_dim as p
on stg.product_name=p.product_name
inner join stg_2_ship_method_dim as s
on stg.ship_mode=s.ship_mode
inner join stg_2_location_dim as l
on stg.postal_code=l.location_id_pk

You might also like