SELECT
C.CustomerID, C.CustomerName,
C.CustomerType, C.Address1,
C.City, C.State, SUM(S.Sales) as TotalSales
FROM
Customers C
INNER JOIN Sales S
ON C.CustomerID = S.CustomerID
GROUP BY
C.CustomerID, C.CustomerName,
C.CustomerType, C.Address1, C.City, C.State
Subscribe to:
Post Comments (Atom)
3 comments:
I believe, the problem lies with the function SUM and the Inner Join. An Inner join cannot be placed on a fied which supposed to be used as a cummulative one!
Hope to get more ideas on this ...
Problem is in Group by clause it must contains SUM(S.Sales).
(Aamir Ali Shah)
(syedsoftware@hotmail.com)
Problem is that INNER JOIN .I think we need to put LEFT JOIN insteadof INNER JOIN for that becuase if is there no Sales against customer that customer will never show in the Query results.
Post a Comment