0

I am doing a school assignment but I do not know how to populate a fact table. My query to do it is

Select CustomerID from dim_cust
Select ProductID from dim_product
select InvoiceID from dim_invoice

insert into [dim_fact] ([CustomerID], [ProductID], [InvoiceID]);

The dim_* are all tables that I filled in manually.

I get also get an "Incorrect syntax near ')'" error. I also have a column that will have the total number of invoices in the fact table (dim_fact).

Any help is greatly appreciated, thank you!

Code

Product Table

Invoice Table

Customer Table

fact table

  • Please share table structures of dim_cust, dim_product and dim_invoice tables – Kazi Mohammad Ali Nur Romel May 02 '21 at 16:14
  • 1
    A fact table has more than just values from your dimensions. Though for how to do an `INSERT` have a read of a tutorial or the documentation; you'll see your `INSERT` statement is incomplete. – Thom A May 02 '21 at 16:14
  • As per the question guide, please DO NOT post images of code, data, error messages, etc. - copy or type the text into the question. Please reserve the use of images for diagrams or demonstrating rendering bugs, things that are impossible to describe accurately via text. – Dale K May 02 '21 at 20:23

1 Answers1

0

I assume that invoice table has both customerid and productid information. So you can join dim_cust and dim_invoice table to get what you want.

insert into [dim_fact] 
select c.[CustomerID], i.[ProductID], i.[InvoiceID]
from dim_cust c inner join dim_invoice i on c.customerid=i.customerid;