以下代码用于获取帮助台任务的计数,我正在尝试检索特定部门的计数。但是,它似乎无法正常工作,我不知道为什么会这样。 SQL查询如下:
SELECT
datepart(mm, m.creationdate) AS themonth,
datepart(yyyy, m.creationdate) AS theyear,
count(*) AS total, count(nullif(m.thetype, '1')) AS regular,
count(nullif(m.thetype, '2')) AS multi,
count(nullif(m.thetype, 11)) AS quick,
count(nullif(m.enteredby, 'WriteLog')) AS mn,
Count(case when m.thetype=10 then 1 else null end) as Errors,
Count(case when m.thetype=12 then 1 else null end) as FOH
FROM mlist AS m
INNER JOIN TypeList AS t ON t.typekey = m.thetype
INNER JOIN Notes AS mn ON m.id = mn.id
WHERE mn.enteredby in ('210','181','229','240','266','284','291','238','239','272','273')
GROUP BY datepart(mm, m.creationdate), datepart(yyyy, m.creationdate)
ORDER BY datepart(yyyy, m.creationdate) DESC, datepart(mm, m.creationdate) DESC
我最近添加了部分:
WHERE mn.enteredby in ('210','181','229','240','266','284','291','238','239','272','273')
在许多情况下导致更高的计数,除非它们是重复的结果,否则没有任何意义。这里有明显的问题吗?