您好我有这个问题:
strSQL = "SELECT DATEPART(yyyy,ArriveDate) AS God," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 1 THEN DATEPART(d,ArriveDate) END)As m1 ," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 2 THEN DATEPART(d,ArriveDate) END)As m2 ," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 3 THEN DATEPART(d,ArriveDate) END)As m3 ," & _
"COUNT (CASE DATEPART(d,ArriveDate) WHEN 4 THEN DATEPART(d,ArriveDate) END)As m4 " & _
" FROM Company " & _
" WHERE DATEPART(yyyy,ArriveDate) =" & [Forms]![Raport_lunar_anual_carnete]![ANUL] & _
" AND DATEPART(mm,ArriveDate)= " & [Forms]![Raport_lunar_anual_carnete]![LUNA] & _
" GROUP BY DATEPART(yyyy,ArriveDate)"
它告诉我:关键字“AND”附近的语法错误
答案 0 :(得分:0)
试试这个
strSQL = " SELECT DATEPART(yyyy,ArriveDate) AS God,"
strSQL = strSQL & " COUNT (CASE DATEPART(d,ArriveDate) WHEN 1 THEN DATEPART(d,ArriveDate) END)As m1 ,"
strSQL = strSQL & " COUNT (CASE DATEPART(d,ArriveDate) WHEN 2 THEN DATEPART(d,ArriveDate) END)As m2 ,"
strSQL = strSQL & " COUNT (CASE DATEPART(d,ArriveDate) WHEN 3 THEN DATEPART(d,ArriveDate) END)As m3 ,"
strSQL = strSQL & " COUNT (CASE DATEPART(d,ArriveDate) WHEN 4 THEN DATEPART(d,ArriveDate) END)As m4 ,"
strSQL = strSQL & " FROM Company "
strSQL = strSQL & " WHERE DATEPART(yyyy,ArriveDate) =" & [Forms]![Raport_lunar_anual_carnete]![ANUL] &
strSQL = strSQL & " AND DATEPART(mm,ArriveDate)= " & [Forms]![Raport_lunar_anual_carnete]![LUNA] &
strSQL = strSQL & " GROUP BY DATEPART(yyyy,ArriveDate)"