oracle数据库,如何把以下三条sql合并成一条查询出来?

select count(1) as flowNum from ccform_debit_all where cf_acctime > to_char(sysdate,'yyyy-MM-dd');
select count(1) as flowNumMonth from ccform_debit_all where cf_acctime > to_char(sysdate,'yyyy-MM');
select count(1) as flowNumTotal from ccform_debit_all where cf_acctime > to_char(sysdate,'yyyy');
阅读 2k
2 个回答
select count(case when to_char(cf_acctime, 'yyyy-MM-dd') > to_char(sysdate, 'yyyy-MM-dd') then 1 end) as flowNum,
       count(case when to_char(cf_acctime, 'yyyy-MM') > to_char(sysdate, 'yyyy-MM') then 1 end)       as flowNumMonth,
       count(case when to_char(cf_acctime, 'yyyy') > to_char(sysdate, 'yyyy') then 1 end)             as flowNumTotal
from ccform_debit_all
新手上路,请多包涵

就union一下??

select count(1) as flowNum from ccform_debit_all where cf_acctime > to_char(sysdate,'yyyy-MM-dd') union all 
select count(1) as flowNumMonth from ccform_debit_all where cf_acctime > to_char(sysdate,'yyyy-MM') union all 
select count(1) as flowNumTotal from ccform_debit_all where cf_acctime > to_char(sysdate,'yyyy');
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题