Professional Documents
Culture Documents
Laboratory Exercises #2
Laboratory Exercises #2
Laboratory Exercises #2
1. Open SQL Server Management Studio and create database name DW. (Please refer to your
previous laboratory exercises on how to create database TestDB)
Then in your newly created DW database, paste the script below and click <Execute> to create 4 new
tables (DimCalendar, DimCustomer, DimProducts and FactSales)
3. Then Create an SQL View named (vw_FactSalesSummary) to join the 4 tables DimCalendar,
DimCustomer, DimProducts and FactSales with the following columns included.
4. Using the view vw_FactSalesSummary, create a query that will generate the following reports
1. Send the query of the view and the 4-Sales summary report on a separate doc or note (not
screenshot).
2. Send the screenshot of the result query (views and the 4 Sales summary reports)
4. For those who doesn’t have PC/Laptop, create a step-by-step process on how are you going to
generate the view and the 4 Sales Summary reports (same to what you did last lab exercises). Using the
4 CSV files as a reference, please generate the report and place it on excel or any docs that you can
display the reports in table like below.
Reference:
SELECT c.CalendarDay,c.WeekNumber
,fs.*
,p.ProductName, p.Price AS 'PricePerUnit'
,(fs.Qty * p.Price ) AS TotalAmountSold
FROM [dbo].[FactSales] fs
JOIN [dbo].[DimCalendar] c ON fs.DateSold=c.CalendarDate
JOIN [dbo].[DimProducts] p ON p.ProductNo=fs.ProductNo
AND fs.DateSold BETWEEN P.EffectiveStartDate AND
ISNULL(p.EffectiveEndDate,GETDATE())