SELECT COMNAME,(SELECT COUNT(GENDER)FROM EMP WHERE GENDER='M' AND COMNAME='B') AS MALE,(SELECT COUNT(GENDER)FROM EMP WHERE GENDER='F' AND COMNAME='B') AS FEMALE FROM EMP
WHERE COMNAME='B' GROUP BY COMNAME