【问题标题】:count function in sql oracle without using group bysql oracle中的count函数不使用group by
【发布时间】:2021-11-26 22:15:51
【问题描述】:

如何在sql oracle中使用count函数而不使用group by?

select count(*) as "Total orders",
       nvl(
         (select count (*)
          from   education
          where status='APPROVED'),
         0
       ) as "Number of approved requests"
from   education

【问题讨论】:

    标签: oracle-sqldeveloper


    【解决方案1】:

    使用条件聚合:

    select COUNT(*) as "Total orders",
           COUNT(CASE status WHEN 'APPROVED' THEN 1 END)
             as "Number of approved requests"
    from   education_expense
    

    【讨论】:

      猜你喜欢
      • 2012-11-20
      • 1970-01-01
      • 2021-04-25
      • 1970-01-01
      • 2011-04-18
      • 2012-06-30
      • 2012-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多