我收到以下错误“错误编号:1064您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的“1 Sum(picker_sign_out_sheet.lines_on_order) AS LINES, staff.staff_name AS PICKER”附近使用的正确语法我不知道从哪里开始,希望得到一些帮助("SELECT TOP 1 Sum(picker_sign_out_sheet.lines_on_order) AS LINES, staff.staff_name AS PICKERFROM picker_sign_out_sheet INNER JOIN staff ON picker_sign_out_sheet.staff_name = staff.staff_idWHERE (((picker_sign_out_sheet.finish_date)=Date()))GROUP BY staff.staff_nameORDER BY Sum(picker_sign_out_sheet.lines_on_order) DESC");我期望得到 1 个结果,显示哪个用户的 lines_on_order 总和最高。任何帮助都会很棒
2 回答
宝慕林4294392
TA贡献2021条经验 获得超8个赞
TOP 1 不是 MySQL 语法
正确的查询是
SELECT Sum(picker_sign_out_sheet.lines_on_order) AS LINES, staff.staff_name AS PICKER
FROM picker_sign_out_sheet INNER JOIN staff ON picker_sign_out_sheet.staff_name = staff.staff_id
WHERE (((picker_sign_out_sheet.finish_date)=Date()))
GROUP BY staff.staff_name
ORDER BY Sum(picker_sign_out_sheet.lines_on_order) DESC
LIMIT 1
- 2 回答
- 0 关注
- 143 浏览
添加回答
举报
0/150
提交
取消