拥有后显示行(oracle)

Display rows after having (oracle)

我有下面的select(这样会更联合):

select column_name,'my_table', count(*)
from my_table
where col10 = 'TEST' 
group by column_name
having count(*) > 1

union all

select column_name,'my_table2', count(*)
from my_table2
where col10 = 'TEST' 
group by column_name
having count(*) > 1

union all...;

在 运行 语句之后,我从 my_table2.

中得到了 0 行

然后可以显示如下所示的内容吗??

为每个 table

添加另一个 UNION ALL
union all

select '-', 'my_table2', 0
from dual
where not exists
(
  select 1
  from my_table2
  where col10 = 'TEST' 
  group by column_name
  having count(*) > 1
)

也许是这样的:

select nvl(sq.column_name, '-') as column_name, tn.table_name,
       nvl(sq."count > 1", 0)   as "count > 1"
from   ( 
         select "my_table"  as table_name from dual union all
         select "my_table2"               from dual -- [ ... union all ... etc]
       ) tn
     left outer join
       (
         -- ENTER YOUR CURRENT QUERY HERE, AS A SUBQUERY
       ) sq
       on tn.table_name = sq.table_name
;