Thank you, I'm making a little headway here as I can get the following code to return the first column for "ChartSales " correctly. Now I'm trying to add 2 more columns that sum different product sales.
The working portion of the code for 1 product is this so far. This gives the correct return.
Now i'm trying to add the additional 2 more columns for the other products and mucking it up, I'm not exactly sure how to add the second or third where statement.
**Admin Edit**
This question was posted as a response to a previous thread SQL Query Showing Total Sales by Each Person and Each Product.
This starts from a position where the following SQL is available as the source for a CrossTab :
The working portion of the code for 1 product is this so far. This gives the correct return.
Code:
SELECT sales_persons.Name, SUM(orders_table.Quantity) AS ChartSales INNER JOIN sales_persons ON sales_persons.PersonID = orders_table.PersonID WHERE orders_table.ProductID = 1 GROUP BY sales_persons.Name
Code:
SELECT sales_persons.Name, SUM(orders_table.Quantity) AS ChartSales, SUM(orders_table.Quantity) AS GaugeSales, SUM(orders_table.Quantity) AS MAPSales FROM orders_table INNER JOIN sales_persons ON sales_persons.PersonID = orders_table.PersonID WHERE orders_table.ProductID = 1 ?????????????? ON sales_persons.PersonID = orders_table.PersonID WHERE orders_table.ProductID = 2 ??????????????? ON sales_persons.PersonID = orders_table.PersonID WHERE orders_table.ProductID = 3 GROUP BY sales_persons.Name
This question was posted as a response to a previous thread SQL Query Showing Total Sales by Each Person and Each Product.
This starts from a position where the following SQL is available as the source for a CrossTab :
Code:
SELECT tSR.Name , tSR.Region , tP.Name , SUM(tS.TotalSales) AS TotalProdSales FROM ([Sales] AS tS INNER JOIN [SalesRep] AS tSR ON tS.PersonNum = tSR.PersonNum) INNER JOIN [Products] AS tP ON tS.ProductNum = tP.ProductNum GROUP BY tSR.Name , tSR.Region , tP.Name
Comment