Help with this query in SQL Posted June 21, 2016 Try something like this... select Sector, (select count(type) from sectors b where a.sector = b.sector and type = 'X') AS "Nr of X", (select count(type) from sectors b where a.sector = b.sector and type = 'Y') AS "Nr of Y", (select count(type) from sectors b where a.sector = b.sector and type = 'Z') AS "Nr of X" from Sectors a group by sector
Help with this query
in SQL
Posted
Try something like this...
select Sector,
(select count(type) from sectors b where a.sector = b.sector and type = 'X') AS "Nr of X",
(select count(type) from sectors b where a.sector = b.sector and type = 'Y') AS "Nr of Y",
(select count(type) from sectors b where a.sector = b.sector and type = 'Z') AS "Nr of X"
from Sectors a
group by sector