关于sql 没有记录要显示成0的问题
来源:百度知道 编辑:UC知道 时间:2024/06/27 07:43:12
SELECT
count(cd)
FROM
t
要实现没有记录的时候,查询出来是0怎么实现呢?
select isnull(count(cd),0) from t
运行结果是:
ERROR: function isnull(bigint, integer) does not exist
count(cd)
FROM
t
要实现没有记录的时候,查询出来是0怎么实现呢?
select isnull(count(cd),0) from t
运行结果是:
ERROR: function isnull(bigint, integer) does not exist
SELECT
count(cd)
FROM
t
你这么写的就是查出没结果的是0啊
select isnull(count(cd),0) from t
这个是正解
用nvl
select nvl(count(cd),0) form t
也可以用decode
select decode(count(cd),null,0) from t
isnull()函数
select isnull(null,0)
select isnull(count(cd),0) from t
SELECT count(cd) FROM t
如果没有记录,它确实返回0