如何比较蜂巢表时计算的记录的百分比是多少?

问题描述 投票:0回答:1

两个叫Table 1和Table蜂巢表是在那里。我得到了这两个表的计数。我创建了一个名为ABC从表1和表2的非匹配记录的第三表。我怎样才能在表ABC记录数的比较的Table 1和Table整个点票的百分比是多少?

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%
sql hadoop hive
1个回答
0
投票

你们是不是要做到这一点在一个声明?

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;
© www.soinside.com 2019 - 2024. All rights reserved.