高手们进来帮忙啊!!统计查询问题 在线等
表 tblEmp
FEmpCodeFEmpNameFNOFDate
A001李12007/05/16
A002李12007/04/12
A003黄12007/05/12
A004李02007/05/12
A005黄02007/04/12
现在要做一个统计查询得到结果
5月(FNO=1) 5月(FNO=0) 4月((FNO=1) 4月((FNO=0)
黄 1 1
李 1 1 1
下面是我的查询语句:
TRANSFORM Count(tblEmp.FNO) AS FNOOfCount
SELECT tblEmp.FEmpName
FROM tblEmp
GROUP BY tblEmp.FEmpName
PIVOT Switch([FNO]=1 And Format([FDate], "mm ")= "05 ", "[FNO]=1 And Format([FDate], 'mm ')= '05 ' ",[FNO]=0 And Format([FDate], "mm ")= "05 ", "=0 ",[FNO]=1 And Format([FDate], "mm ")= "04 ", "=1 ",[FNO]=0 And Format([FDate], "mm ")= "04 ", "=0 ",True, "others ") In ( "=1(05) ", "=0(05) ", "=1(04) ", "=0(04) ", "others ");
但是结果出不来
大家帮忙看看啦!!!
[解决办法]
TRANSFORM Count(FNO) AS FNOOfCount
SELECT FEmpName
FROM tt
GROUP BY FEmpName
pivot Format([FDate], "mm ") & "月 " & "(fno= " & fno & ") "