非常感谢您的热心指点,我用iif函数一次查询就能实现了,在此拿出来与大家一起分享。
SELECT 工作职名, sum(iif(年龄 Between 24 And 29,1,0)) AS 24~29岁, sum(iif(年龄 Between 30 And 34,1,0)) AS 30~34岁, sum(iif(年龄 Between 35 And 39,1,0)) AS 35~39岁, sum(iif(年龄 Between 40 And 44,1,0)) AS 40~44岁, sum(iif(年龄 Between 45 And 49,1,0)) AS 45~49岁, sum(iif(年龄 Between 50 And 54,1,0)) AS 50~54岁, sum(iif(年龄 Between 55 And 59,1,0)) AS 55~59岁, sum(iif(年龄=60,1,0)) AS 60岁, count(*) AS 合计
FROM 人员表
GROUP BY 工作职名;
非常感谢您的热心指点,您的方法可行,不过我用iif函数一次查询就能实现了,在此拿出来与大家一起分享。
SELECT 工作职名, sum(iif(年龄 Between 24 And 29,1,0)) AS 24~29岁, sum(iif(年龄 Between 30 And 34,1,0)) AS 30~34岁, sum(iif(年龄 Between 35 And 39,1,0)) AS 35~39岁, sum(iif(年龄 Between 40 And 44,1,0)) AS 40~44岁, sum(iif(年龄 Between 45 And 49,1,0)) AS 45~49岁, sum(iif(年龄 Between 50 And 54,1,0)) AS 50~54岁, sum(iif(年龄 Between 55 And 59,1,0)) AS 55~59岁, sum(iif(年龄=60,1,0)) AS 60岁, count(*) AS 合计
FROM 人员表
GROUP BY 工作职名;