User283571144 posted
Hi marya,
According to your sql query, I suggest you could try to use group by to achieve your requirement.
More deails, you could refer to below query:
Select re.Department, SUM(re.Female), SUM(re.Male) from(
SELECT c.Name, count(Staff.StaffId) as Male, 0 as Female
FROM Registrations AS e INNER JOIN
Branch AS c ON e.RegistrationID = c.RegistrationID
WHERE (Staff.GenderTypeID = 1)
GROUP BY c.Name
UNION ALL
SELECT c.Name, 0 as Male, count(Staff.StaffId) as Female
FROM Registrations AS e INNER JOIN
Branch AS c ON e.RegistrationID = c.RegistrationID
WHERE (Staff.GenderTypeID = 2)
GROUP BY d.Name)
As Re group by re.Department
Result:

Best Regards,
Brando