10:38:40 select tm from `ecrs_improvement_employee_details` where RZRJ<='2023/5/31' and LZRJ is null and count(tm)>2 and QY='浸潭' group by tm Error Code: 1111. Invalid use of group function 0.000 sec
时间: 2024-03-08 22:48:22 浏览: 17
这个 SQL 查询语句的错误是因为在 `where` 子句中使用了聚合函数 `count()`,而这个函数只能在 `select` 子句或 `having` 子句中使用。你需要将 `count(tm) > 2` 的条件移动到 `having` 子句中,如下所示:
```
select tm
from `ecrs_improvement_employee_details`
where RZRJ <= '2023/5/31' and LZRJ is null and QY='浸潭'
group by tm
having count(tm) > 2;
```
这样就可以正常执行查询语句了。注意,`having` 子句必须放在 `group by` 子句之后。