select c_name, count (*) from (select t.techname, t.departid, d.c_name
from tech_info t left join in depart d on t.departid = d.departid) a group by t.t.departid, t.c_name
SELECT COUNT (*) AS techCount, c_Name
FROM eis_tech_info INNER JOIN eis_dict_depart ON
eis_tech_info.departid = eis_dict_depart.i_code
GROUP BY eis_tech_info.departid
select c_name, count (*) from (select t.techname, t.departid, d.c_name
from dbo.eis_tech_info t left join dbo.eis_dict_depart d on t.departid = d.i_code) a group by departid, c_name