我有两组不同的表。我想比较两个表中的总数,并想显示两个表计数是否匹配。如果匹配,则"通过"否则"失败"。
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中创建任何变量?
好的,完成此操作很容易。如下:
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