I want to count the number of different sheep, and I want it in one table.
Like this;
Ewes | Rams | Lambs
8 | 5 | 12
The query I try is this, but it doesn't work;
SELECT COUNT(e.EweID) AS 'Ewe', COUNT(r.RamID) AS 'Ram', COUNT(l.LambID) AS 'Lamb'
FROM Sheep s
INNER JOIN Ewe e ON s.SheepID = e.EweID
INNER JOIN Ram r ON s.SheepID = r.RamID
INNER JOIN Lamb l ON s.SheepID = l.LambID
WHERE s.FarmerID = '123'
I don't get what I'm doing wrong, this is my database ERD;
