我尝试了该查询的几次迭代,并不断出现语法错误。我曾经尝试过使其成为子查询,但是通过内部联接,它出现了其他语法错误。任何建议将不胜感激。
我正在尝试拉每个工作人员的联系人。
SELECT Stafflist.Staff, Count(distinct Contact) as count
FROM Contacts INNER JOIN
StaffList
ON Contacts.ID = Stafflist.ID
WHERE ((Contacts.Date) Between #1/1/2020# And #1/5/2020#) AND Contacts.status='Finished')
GROUP BY Staff,
ORDER BY Staff;
答案 0 :(得分:2)
MS Access不支持COUNT(DISTINCT)
。但是您可以使用子查询:
SELECT Stafflist.Staff, Count(Contct) as count
FROM (SELECT DISTINCT Stafflist.Staff, Contacts.Contact
FROM Contacts INNER JOIN
StaffList
ON Contacts.ID = Stafflist.ID
WHERE Contacts.Date Between #1/1/2020# And #1/5/2020# AND
Contacts.status = 'Finished'
) as SC
GROUP BY Staff,
ORDER BY Staff;