Oracle - return multiple counts as one query

前端 未结 3 1596
旧巷少年郎
旧巷少年郎 2021-02-19 11:50

I have a couple of queries, detailed below. I\'d like to be able to run one SQL query which returns both counts, is this possible?

1.

select nvl(count(ro         


        
3条回答
  •  感动是毒
    2021-02-19 12:18

    If the condition really looks like that (same table, only one field different in the groups):

    select opp, count(*) from tablename
    where date = 'BAZ'
    group by opp
    having opp in ('FOO', 'BAR');
    

    For arbitrary queries:

    select 'A', count(*) from tableA
    union all
    select 'B', count(*) from tableB
    

提交回复
热议问题