-2

I have 3 tables .

1.Customers Table(CustomerID,CustomerName)
2.SalesTable(SalesChannel,CustoemrID,SalesID)
3.TransactionTable(SalesID,UnitsSold,TotalAmount,SellingDate)

Now i need the Total units sold and total amount for every month of each customer? Please help me with this situation?

M.Ali
  • 67,945
  • 13
  • 101
  • 127
  • possible duplicate of [SQL JOIN and different types of JOINs](http://stackoverflow.com/questions/17946221/sql-join-and-different-types-of-joins) – Tab Alleman Aug 17 '15 at 16:19

1 Answers1

0
SELECT C.CustomerID
      ,C.CustomerName
      ,MONTH(t.SellingDate) AS SalesMonth
      ,SUM(t.UnitsSold * t.TotalAmount) AS TotalSales
FROM       Customers C 
INNER JOIN SalesTable S       ON S.CustomerID = C.CustomerID
INNER JOIN TransactionTable t ON t.SalesID = S.SalesID
GROUP BY C.CustomerID ,C.CustomerName ,MONTH(t.SellingDate)
M.Ali
  • 67,945
  • 13
  • 101
  • 127