我无法想象我的生活。我有以下运行的SQL语句,它告诉我错误在ORDER BY d GROUP BY d;
行
SELECT d, SUM(e) AS Se, SUM(q) AS Sq
FROM table1
WHERE code <> '1b'
AND sDate BETWEEN #2016/08/10# AND #2016/08/17#
ORDER BY d GROUP BY d;
此代码适用于MS Access 2013,因为我在那里有相同的表。在这种情况下,我使用MariaDB,基本上与MySQL相同,所以我不确定是否有任何语法更改,我缺少。
由于
解决
尝试完成后我就开始工作了。出于某种原因,它不喜欢#符号,所以我将它们全部切换为撇号。我还改变了GROUP BY d和ORDER BY d的顺序。
SELECT d, SUM(e) AS Se, SUM(q) AS Sq
FROM table1
WHERE Code <> '1b'
AND sDate BETWEEN '2016-08-10' AND '2016-08-17'
GROUP BY d
ORDER BY d;
答案 0 :(得分:0)
尝试使用
SELECT d, SUM(e) AS Se, SUM(q) AS Sq
FROM table1
WHERE code <> '1b' AND Code <> '2b'
AND sDate BETWEEN #2016/08/10# AND #2016/08/17#
GROUP BY d ORDER BY d ;