0

我在 2 个不同的模式中有同名的表。我想要做的是在格式的 2 个表中进行计数比较

表名:Count1:Count2

如何通过 Hive 查询实现这一点?

4

3 回答 3

0

使用 UNION ALL:

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
于 2019-12-09T15:15:00.253 回答
0

您可以执行cross join计数查询。

select t1.count1,t2.count2
from (select count(*) as count1 from tbl1) t1
cross join (select count(*) as count2 from tbl2) t2
于 2019-12-09T15:15:01.850 回答
0

尝试完全外连接

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; 
于 2019-12-10T10:14:53.947 回答