SELECT inc.incidents_id, DATE_FORMAT(inc.create_time,'%Y-%m-%d') days, COUNT(inc.incidents_id) FROM soc_data.incidents inc JOIN soc_data.incidents_monitor mon ON inc.incidents_id = mon.incidents_id GROUP BY days ASC > 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 'ASC' at line 3 > 时间: 0.022s
时间: 2024-02-21 12:00:54 浏览: 142
APPLICATION-PROJECT-LIST-1.rar_Heart To Heart
这个错误提示告诉我们 ASC 关键字的位置有误,应该放在 COUNT 函数的后面。您需要将 ASC 关键字放在 COUNT 函数的后面,如下所示:
```
SELECT inc.incidents_id, DATE_FORMAT(inc.create_time,'%Y-%m-%d') days, COUNT(inc.incidents_id)
FROM soc_data.incidents inc JOIN soc_data.incidents_monitor mon ON inc.incidents_id = mon.incidents_id
GROUP BY days
ORDER BY COUNT(inc.incidents_id) ASC
```
这样,查询语句就可以正常执行了。注意,我在修改查询语句时添加了一个 ORDER BY 子句,以便按照 COUNT 函数的结果进行排序。
阅读全文