暂无图片
sql查询怎么计算当列空值与非控制比例?
我来答
分享
暂无图片 匿名用户
sql查询怎么计算当列空值与非控制比例?

sql查询怎么计算当列空值与非控制比例?

我来答
添加附件
收藏
分享
问题补充
2条回答
默认
最新
DarkAthena
select decode(count(id),0,null, (count(1)-count(id))/count(id)) from t

id为你要查的列

暂无图片 评论
暂无图片 有用 1
暂无图片
chengang
2021-10-14
count(1)-count(字段) 这个方法好。不用写case了。
chengang
with cte1 as( select 1 as id union all select 2 union all select null union all select 3 union all select null ), cte2 as( select count(id) as cnt_notnull,count(case when id is null then 0 else null end) as cnt_null from cte1 ) select *,case when cnt_notnull = 0 then 0 else cnt_null/cnt_notnull *100 end as rate from cte2

cnt_notnull cnt_null rate
3 2 66.6667

暂无图片 评论
暂无图片 有用 0
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏