把SQL查询结果为null值 替换为0

方法1:使用isnull替换
select keyId,isnull(info,0) as info from test

---方法2:使用case when 替换
select keyId,case when info is null then 0 else info end as info from test

---方法3:使用coalesce替换相应的值
select keyId , coalesce(info,0) as info from test
posted @ 2022-07-21 16:20  向前追起  阅读(9589)  评论(0编辑  收藏  举报