microsoftaccess->distinct count带有内部连接和多个选择

mnemlml8  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(302)

我已经尝试了几次这个查询的迭代,并且不断得到语法错误。我一度尝试将其作为子查询,但使用内部连接时,它会出现额外的语法错误。任何建议都将不胜感激。
我试着把每个员工的联系方式都拉出来。

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;
eqfvzcg8

eqfvzcg81#

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;

相关问题