我的mysql查询是
SELECT
testid,
testName,
DATE(testviewaudit.datetime) ,
SUM(action=1) AS view,
SUM(action=2) AS start,
SUM(action=3) AS finish
FROM testviewaudit
INNER JOIN tmtests
ON estviewaudit.testid = tmtests.tsid
WHERE DATE(testviewaudit.datetime) >= '2016-03-12'
AND DATE(testviewaudit.datetime) <= '2016-03-15'
GROUP BY testid;
在使用上述查询时,我得到了1064错误
最佳答案
您只在查询之间使用
SELECT
testid,
testName,
DATE(testviewaudit.datetime),
SUM(action = 1) AS view,
SUM(action = 2) AS start,
SUM(action = 3) AS finish
FROM testviewaudit INNER JOIN tmtests ON estviewaudit.testid = tmtests.tsid
WHERE DATE(testviewaudit.datetime) between '2016-03-12'
AND '2016-03-15' GROUP BY testid;