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