这是我的表结构:
团队
t_id => int(11)
t_name => varchar(256)
销售量
s_id => int(11)
s_amount => int(11)
s_date => date
team_id => int(11)
我想总结所有团队在特定时间段内的所有销售额。这是我的 SQL 命令:
SELECT
t_name,
SUM(s_amount) as total_amount,
FROM teams
JOIN sales ON sales.team_id=teams.t_id
GROUP BY sales.team_id
WHERE s_date BETWEEN '2013-09-01'
AND '2013-09-08';
如果我在 phpmyadmin 中执行这个命令,它会说:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE s_date BETWEEN '2013-09-01' AND '2013-09-08' L' at line 10
我在这里做错了什么?