我有两组不同的表。我想比较两个表中的总数,并想显示两个表中的计数是否匹配。如果匹配,则“通过”,否则为“失败”。
SELECT (SELECT COUNT (*)
FROM Table1 t1
INNER JOIN Table2 t2
ON TRIM (t1.mgac_ac_id) = TRIM (t2.account))
AS cnt1,
(SELECT COUNT (*) FROM t3) AS cnt2 where cnt1=cnt2;
以上显示代码不正确。任何人都可以在代码方面提供帮助。是否要在HIVE中创建任何变量?
答案 0 :(得分:2)
好,完成此操作很简单。如下所示:
select
case when tmp1.value = tmp2.value then 'Pass' else 'Fail' end as result
from
(select count(1) as value from table1) tmp1
join
(select count(1) as value from table2) tmp2 on 1=1