我有一个在多个表中具有相同名称字段的 Oracle 数据库。它看起来像这样:
table1 table2 table3 table4
field field field field
每个表中的公共字段可以是“是”、“否”或空值。我试图在一个查询中获取所有字段的值计数,但我无法弄清楚。基本上我想要这个:
field table1_cnt table2_cnt table3_cnt table4_cnt
yes 20 25 30 35
no 35 25 15 5
null 8 6 7 5
到目前为止我有这个,但它只适用于一张桌子,而不是多张桌子。
select field, count(*) as table1_cnt
from table1
group by field
_____________________________________
field table1_cnt
yes 20
no 35
null 8