Reputation:
Include all records from table1 and only include records from table2 where the ID field is equal.
Select
Count(uno.itemID) As [Merchandise Sold],
uno.salesmanName As [Who Got Sale],
COUNT(duo.SalesCancelled) As [Bring it Back]
FROM table1 uno
INNER JOIN table2 duo
ON uno.itemID = duo.itemID
Group By uno.salesmanName
I have tried inner, right, left but am not getting expected outcome
Upvotes: 0
Views: 36
Reputation: 1269813
I think you want a left join
because you say you want to keep everything in the first table:
Select Count(uno.itemID) As [Merchandise Sold],
uno.salesmanName As [Who Got Sale],
COUNT(duo.SalesCancelled) As [Bring it Back]
FROM table1 uno LEFT JOIN
table2 duo
ON uno.itemID = duo.itemID
Group By uno.salesmanName;
Upvotes: 1