Building a sales query in MS SQL Server
Before we can start visualizing our amazing data in Tableau, we must first put together the query that will provide us thatĀ amazing data. We have been asked to put together a sales dashboard that highlights sales from different marketing promotions that have been initiated since the start of AdventureWorks
. This promotional data is located in the Sales.SalesReason
table in the data warehouse, as seen in the following screenshot:
These results show that there are ten different possible promotions that could have resulted in a sale. The actual sales data is in the Sales.SalesOrderHeader
table but that table does not have the SalesReasonID
for us to join sales to promotions. The SalesOrderHeader
table has a SalesOrderID
, as seen in the following script:
SELECT distinct [SalesOrderID] FROM [AdventureWorks2014].[Sales].[SalesOrderHeader]
We will need to find a table that can tie SalesOrderID
to SalesReasonID
. Fortunately, we have a table...