TRANSFORM nz(Count([出诊编号]),0) AS 出诊编号之计数
SELECT 表1.住院科室, Count(表1.出诊编号) AS 总计
FROM 表1
GROUP BY 表1.住院科室
PIVOT 表1.出诊地点
in(a,b,c,d);
[em17]也可以这样:
SELECT 住院科室, sum(iif(出诊地点='a',1,0))+sum(iif(出诊地点='b',1,0))+sum(iif(出诊地点='c',1,0))+ sum(iif(出诊地点='d',1,0)) AS 合计, sum(iif(出诊地点='a',1,0)) AS a, sum(iif(出诊地点='b',1,0)) AS b, sum(iif(出诊地点='c',1,0)) AS c, sum(iif(出诊地点='d',1,0)) AS d
FROM 表1
GROUP BY 住院科室;