Microsoft Visual Basic for Applications
-
SQL LEFT JOIN与GROUP BY,COUNT& WHERE子句
问题已解决:感谢您分享链接@Vityata。下面给出了其他人引用的更正代码。
strSQL = "SELECT A.ID, A.Reason, COUNT(B.TimeStamp)" & _
"FROM tblReasons A " & _
"Left Join " & _
"(" & _
"SELECT TimeStamp, Reason FROM tblTracker " & _
"WHERE TimeStamp > #04/11/2017# and TimeStamp < #04/14/2017# " & _
")B ON A.ID = B.Reason " & _
" GROUP BY A.ID, A.Reason"
答案 0 :(得分:1)
执行以下操作。
?strsql
然后按回车,询问VBE整个事情是什么。 (见下图) 一般来说,我认为GROUP BY和LEFT JOIN有点不对,但我应该看到数据告诉你更多。 SQL - Group By with Left Join