count()为空时取值为0


通过count(行数)可以取到0

with
ect1 as
  (select id from user where is_blacklist=0),
ect2 as
  (select s1.id,s1.type,s1.date
  from email s1 where s1.send_id in ect1
  and s1.receive_id in ect1
  ),
ect3 as
  (select a.date,count(a.id) as num1,

    <!----以下通过取行数获得cout()为0------>
    (select count(1) from ect2 b
      where type='no_completed' and a.date=b.date) as num2
  from ect2 a
  group by date)
select date,cast(num2 as FLOAT)/cast(num1 as flaot) from ect3


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM