我在两个不同的模式中有同名的表。我要做的是在格式中的两个表中进行计数比较表名:count1:count2如何通过配置单元查询实现这一点?
guykilcj1#
全部使用:
select 'db1.table_name' table_name, count(col1) count1, count(col2) count2 from db1.table_name UNION ALL select 'db2.table_name' table_name, count(col1) count1, count(col2) count2 from db2.table_name
dbf7pr2w2#
尝试完全外部连接
select tt1.cn,tt2.cn from (select count(1) as cn from db1.table) tt1 full outer join (select count(1) as cn from db2.table ) tt2 on tt1.cn=tt2.cn;
r55awzrz3#
你可以做一个 cross join count个查询。
cross join
select t1.count1,t2.count2 from (select count(*) as count1 from tbl1) t1 cross join (select count(*) as count2 from tbl2) t2
3条答案
按热度按时间guykilcj1#
全部使用:
dbf7pr2w2#
尝试完全外部连接
r55awzrz3#
你可以做一个
cross join
count个查询。