Reputation: 169
I need to show the number of salespeople who represent at least one studio, each. My studios table resembles the following:
Studios
-------
StudioID, Studioname, Email, SalesID
The Salespeople table resembles the following:
Salespeople
---------------
SalesID, Firstname, Lastname
I formulated the following query:
SELECT sp.firstname,
sp.lastname,
Count(sp.salesid) AS NumberOfSalesPeople
FROM salespeople sp
JOIN studios s
ON s.salesid = sp.salesid
HAVING Count(s.studioid) > 0;
However, I do not think it is completely correct. Again, the question is: show the number of salespeople who represent at least one studio each.
Upvotes: 2
Views: 249
Reputation: 43434
I need to show the number of salespeople who represent at least one studio, each
The answer to that requirement would be:
SELECT COUNT(DISTINCT SalesId) NumberOfSalesPeople FROM Studios
Not sure why you've added so much additional information in the query you've formulated.
Upvotes: 2