select case when sspcs is null then count(*) else '0' end from jub_sh_sh 这个SQL有错吗
时间: 2023-05-20 15:01:15 浏览: 71
这个SQL语句是有错误的,因为在select语句中不能同时使用count(*)和'0'。正确的写法应该是:select case when sspcs is null then count(*) else 0 end from jub_sh_sh。
相关问题
为什么在这个SQL中不添加group by sspcs就报错
这个问题可能是因为在SELECT语句中使用了聚合函数,但是没有使用GROUP BY子句对结果进行分组。如果你想对结果进行分组,需要在SELECT语句中添加GROUP BY子句,并指定需要分组的列。如果你不需要对结果进行分组,可以使用聚合函数的OVER()函数来计算聚合值。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)