Showing posts with label Adventure Works. Show all posts
Showing posts with label Adventure Works. Show all posts

Tuesday, December 28, 2010

Holisitic Data Warehousing Book and free Template is now launched.

Today our Holistic Data Warehousing book and free downloadable & universal Data Warehouse Template for SQL Server 2008 has been released.

The book is not the typical IT book that is written by I.T. professionals for I.T. professionals/students. Instead we are both business people with vast experience in using I.T. for reporting purposes and the book is mainly directed at fellow business people with good skills in spreadsheeting, databases and extracting data.

The template is groundbreaking in that it is designed for any business to use without modification to implement a full, across the business, data warehouse. The book fully documents the model, explains our take on data warehousing and explains the strategy behind our idea of Full Supply Chain reporting. The template download includes some reporting models that enable Full Supply Chain reporting from the one system. Also inlcuded in the book is documentation of a comprehensive load from the Microsoft Adventure Works SQL database for demonstration purposes.

We expect the book will receive mixed reviews with some being very critical and others favourable. Critics will make the point that our methods are very basic and not "correct" according to standards that have been established over past decades. We acknowledge that the Holistic Data Warehousing methodology is rule breaking but this is a deliberate attempt to simplify the model as much as possible. There is a chapter in the book devoted to the topic of data warehousing rules. The Holistic model was built with current and future technology in mind and would have been practically impossible to use 10 years ago for mainstream businesses.

As a business person, with some experience with databases such as Microsoft Access, your will learn from this book how to implement a full data warehouse and to do it yourself. This is not just any data warehouse it is the "Holistic" data warehouse that has been designed by the Authors to provide a system capable of virtually any business intelligence reporting.

The only cost to your business to implement Full Supply Chain reporting using the Holistic Data Warehouse is your time, Microsoft SQL Server and Windows Server software and a server class PC. This can be done for as little as $30,000 depending on the Microsoft server license costs.

42sight.com exists to support the users of this new data warehousing methodology. Existing literature explains the complex traditional methods. Our book and this website will for a long while be the main source of information on how to use this new method. We expect our methodology to not gain acceptance amongst the supporters of the traditional data warehousing methods. This website will provide a focal point for supporters of the Holistic method to help each other and for resources to share.

By purchasing the book you are gaining full documentation of the model and are helping to support the authors to support the Holistic Data Warehousing community. If you like our book please "review" it on Amazon and pass on recommendations to your colleagues and acquaintances that might be interested in the book. Our goal is to "free-up" data warehousing and making it affordable for the masses of small to medium business operators.

You will find links to purchase the book, along with links to the model and links to an extract from the first few chapters from the book all on the blog.

Sunday, November 2, 2008

Adventure works 2005- faulty report samples - fixes/solution

Solution for faulty Product line sales:

The Product line sales report has currently for "top employees" the following incorrect query in the dataset TopEmployees:

SELECT TOP 5 C.LastName, C.FirstName, E.EmployeeID, SUM(SOH.SubTotal) AS SaleAmount
FROM Sales.SalesPerson SP INNER JOIN HumanResources.Employee E ON SP.SalesPersonID = E.EmployeeID INNER JOIN Person.Contact C ON E.ContactID = C.ContactID INNER JOIN Sales.SalesOrderHeader SOH ON SP.SalesPersonID = SOH.SalesPersonID INNER JOIN Sales.SalesOrderDetail SOD ON SOH.SalesOrderID = SOD.SalesOrderID INNER JOIN Production.Product P ON SOD.ProductID = P.ProductID INNER JOIN Production.ProductSubcategory PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID INNER JOIN Production.ProductCategory PC ON PS.ProductCategoryID = PC.ProductCategoryID
WHERE (PC.ProductCategoryID = @ProductCategory) AND (PS.ProductSubcategoryID IN (@ProductSubcategory)) AND (SOH.OrderDate > @StartDate) AND (SOH.OrderDate < @EndDate)
GROUP BY C.LastName, C.FirstName, E.EmployeeID, PC.ProductCategoryID, PS.ProductSubcategoryID
ORDER BY SUM(SOH.SubTotal) DESC

The problem is that it is adding up the Sales Order header - for every line on the order - so an order with 10 lines has the Order total multiplied 10 times. The "SUM(SOH.SubTotal)" bits need to be substituted with SUM(SOD.LineTotal).

So the top 5 report should use the following query:
SELECT TOP (100) PERCENT C.LastName, C.FirstName, E.EmployeeID, SUM(SOD.LineTotal) AS SaleAmount
FROM Sales.SalesPerson AS SP INNER JOIN HumanResources.Employee AS E ON SP.SalesPersonID = E.EmployeeID INNER JOIN Person.Contact AS C ON E.ContactID = C.ContactID INNER JOIN Sales.SalesOrderHeader AS SOH ON SP.SalesPersonID = SOH.SalesPersonID INNER JOIN Sales.SalesOrderDetail AS SOD ON SOH.SalesOrderID = SOD.SalesOrderID INNER JOIN Production.Product AS P ON SOD.ProductID = P.ProductID INNER JOIN Production.ProductSubcategory AS PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID INNER JOIN Production.ProductCategory AS PC ON PS.ProductCategoryID = PC.ProductCategoryID
WHERE (PC.ProductCategoryID = @ProductCategory) AND (PS.ProductSubcategoryID IN (@ProductSubcategory)) AND (SOH.OrderDate > @StartDate) AND (SOH.OrderDate < @EndDate)
GROUP BY C.LastName, C.FirstName, E.EmployeeID, PC.ProductCategoryID, PS.ProductSubcategoryID
ORDER BY SUM(SOD.LineTotal) DESC

For the dataset TopCustomers there is an identical mistake
SELECT TOP 5 S.Name AS StoreName, SUM(SOH.SubTotal) AS SaleAmount, PS.ProductSubcategoryID,nPS.ProductCategoryID
FROM Production.Product P INNER JOIN Production.ProductSubcategory PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID INNER JOIN Sales.SalesOrderDetail SOD ON P.ProductID = SOD.ProductID INNER JOIN Sales.Customer CU INNER JOIN Sales.SalesOrderHeader SOH ON CU.CustomerID = SOH.CustomerID INNER JOIN Sales.Store S ON CU.CustomerID = S.CustomerID ON SOD.SalesOrderID = SOH.SalesOrderID
WHERE (SOH.OrderDate > @StartDate) AND (SOH.OrderDate < @EndDate) AND (PS.ProductCategoryID = @ProductCategory) AND (PS.ProductSubcategoryID IN (@ProductSubcategory))
GROUP BY S.Name, PS.ProductSubcategoryID, PS.ProductCategoryID
ORDER BY SUM(SOH.SubTotal) DESC

The correct query is:
SELECT TOP 5 S.Name AS StoreName, SUM(SOD.LineTotal) AS SaleAmount, PS.ProductSubcategoryID,nPS.ProductCategoryID
FROM Production.Product P INNER JOIN Production.ProductSubcategory PS ON P.ProductSubcategoryID = PS.ProductSubcategoryID INNER JOIN Sales.SalesOrderDetail SOD ON P.ProductID = SOD.ProductID INNER JOIN Sales.Customer CU INNER JOIN Sales.SalesOrderHeader SOH ON CU.CustomerID = SOH.CustomerID INNER JOIN Sales.Store S ON CU.CustomerID = S.CustomerID ON SOD.SalesOrderID = SOH.SalesOrderID

WHERE (SOH.OrderDate > @StartDate) AND (SOH.OrderDate < @EndDate) AND (PS.ProductCategoryID = @ProductCategory) AND (PS.ProductSubcategoryID IN (@ProductSubcategory)) GROUP BY S.Name, PS.ProductSubcategoryID, PS.ProductCategoryIDORDER BY SUM(SOD.LineTotal) DESC

I think these work :)

As for the sales territory drilldown the only fix I can see is to do an update query of the Sales Order Header file of the correct line totals from the Sales Order Detail files.

Thursday, October 30, 2008

Problems we are having with Adventure works 2005

Product Line Sales:

Top 5 Customers - sales are inflated significantly. Adventure works sales in total (from the Sales order header) are approx $97M

Do a report (Bikes, road bikes, Calendar year 2003) and the Top 5 Sales people sold over $158 millions - does anyone notice this as a problem ? Just a slight reconciliation difference I would think

Or is this report deliberately broken so people can fix it?


Now my next favourite report:

Sales Territory Drill down

The Sales by Order by Header does agree to the sales order total from the 'Drill down' - hmm housten we have a problem

Australia , Lynn Tsoflias Sales order SO51150 $40,274.01 =/= the drilldown $26,328 (after discount of $1,996)

In fact the Adventure works database is broken - Sales order Header subtotal =/= sum(Sales Order Detail . line total) - total discrepancy a cool $17 mill or so. A redememing fact is that the dbo.FactResellerSales table does indeed have the 'correct' sales number.(It reconciles to the Sales order Detail)

ALSO this report is missing sales made by managers - or dont managers count? (they are also missing from the view Sales.vSalesPerson in the

=======================================
So is there something I am completely missing?

Seriously though I am using Adventure works for SQL server 2005 - are these problems that are fixed in the Adventure works 2008? (havent installed yet as I dont have SQL 2008 yet)

Please feel free to contribute to the discussion