[英]How to calculate the percentage of records when comparing hive tables?
有兩個名為 table1 和 table2 的 Hive 表。 我得到了這兩個表的數量。 我創建了一個名為 abc 的第三個表,其中包含來自 table1 和 table2 的不匹配記錄。 如何獲得表 abc 中的記錄數與 table1 和 table2 的整個計數相比的百分比?
1. select count(*) from table1 A
2. select count(*) from table2 B
3. create table dbo.abc as
select A.column1, A.columnb from table A
inner join table B
where A.column3 <> B.column3
4. how to get the percentage of records in table abc?
for example: count(*) from abc
-------------------- *100
count(*) from A + B
預期輸出為:
Example:
number_of_non_matching_records = 20%
你想在一個聲明中做到這一點嗎?
select count(*) as combos_in_ab,
sum(case when a.column3 <> b.column3 then 1 else 0 end) as combos_in_3,
avg(case when a.column3 <> b.column3 then 1.0 else 0 end) as percent_in_3
from a cross join
b;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.