我正在尝试确定 2007-2013 年间培训课程的出席人数。我需要它来拉动他们在时间范围内所在的员工工作组:
SELECT O867IA_VJOBHST.JOB_CLS_CD, O867IA_VJOBHST.DIS_NR,
Sum(IIf(emp_tng_stt_dt Between #1/1/2007# And #12/31/2011#,1,0)) AS [2007-2011],
Sum(IIf(emp_tng_stt_dt Between #1/1/2011# And #12/31/2011#,1,0)) AS 2011,
Sum(IIf(emp_tng_stt_dt Between #1/1/2012# And #12/31/2012#,1,0)) AS 2012,
Sum(IIf(emp_tng_stt_dt Between #1/1/2013# And #9/23/2013#,1,0)) AS 2013, O867IA_VJOBHST.REC_EFF_STT_DT, O867IA_VTRAING.EMP_TNG_STT_DT
FROM (O867IA_VJOBHST INNER JOIN O867IA_VTRAING ON O867IA_VJOBHST.SYS_EMP_ID_NR = O867IA_VTRAING.SYS_EMP_ID_NR) INNER JOIN O867IA_VPJOBCO ON O867IA_VJOBHST.JOB_CLS_CD = O867IA_VPJOBCO.JOB_CLS_CD
WHERE (((O867IA_VTRAING.REG_NR)="03") AND ((O867IA_VTRAING.TNG_SYS_NR)="0918") AND ((O867IA_VPJOBCO.JOB_GRP_CD)="61"))
GROUP BY O867IA_VJOBHST.JOB_CLS_CD, O867IA_VJOBHST.DIS_NR, O867IA_VJOBHST.REC_EFF_STT_DT, O867IA_VTRAING.EMP_TNG_STT_DT;
REC_EFF_STT_DT 字段是他们在工作中记录的日期,所以我试图让它成为 MAX 日期,并且它需要小于 EMP_TNG_STT_DT ,即培训课程的举办时间。我尝试将其设置为 (((O867IA_VJOBHST.REC_EFF_STT_DT)<[O867IA_VTRAING].[EMP_TNG_STT_DT])); 但每当我将 MAX 添加到 REC EFF STT DT 时,它总是给我一个错误“您尝试执行不包含指定表达式的查询”。我找不到任何解决方案,需要帮助。