高手们进来帮忙啊!!统计查询问题 在线等
表 tblEmp
FEmpCode FEmpName FNO FDate
A001 李 1 2007/05/16
A002 李 1 2007/04/12
A003 黄 1 2007/05/12
A004 李 0 2007/05/12
A005 黄 0 2007/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 & ") "