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 where 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 5 > 时间: 0.131s
时间: 2024-02-21 16:00:51 浏览: 107
APPLICATION-PROJECT-LIST-1.rar_Heart To Heart
根据错误提示,这个 SQL 查询语句有语法错误,错误位于 GROUP BY 子句之后的 "asc"。GROUP BY 子句应该是按照列名来分组的,而 "asc" 不是列名,所以会报错。您需要指定一个列名来替代 "days",例如:
```
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
```
这样,查询语句就可以正常执行了。注意,我在修改查询语句时添加了一个 ON 条件来连接 incidents 和 incidents_monitor 表,因为在原始查询语句中没有指定如何连接这两个表。
阅读全文