select a.id, coalesce(s.cnt, 0) no_matches
from always a
left join (select id, count(*) cnt from sometimes group by id) s
on s.id = a.id
对于表中的每一行 always ,这将检查中有多少行匹配 sometimes . 任何值,除了 1 表示Map问题(完全不匹配或多个匹配)。 您可以生成摘要报告。假设您想要 a 在b中有适当的1-1匹配:
select avg(case when s.cnt = 1 then 1.0 else 0 end) accuracy_ratio
from always a
left join (select id, count(*) cnt from sometimes group by id) s
on s.id = a.id
也许你想产生三个比率:
select
avg(case when s.cnt = 1 then 1.0 else 0 end) accuracy_ratio,
avg(case when s.cnt is null then 1.0 else 0 end) unmatched_ratio,
avg(case when s.cnt > 1 then 1.0 else 0 end) many_matches_ratio,
from always a
left join (select id, count(*) cnt from sometimes group by id) s
on s.id = a.id
1条答案
按热度按时间vi4fp9gy1#
您可以使用sql查询生成每个id的准确度报告:
对于表中的每一行
always
,这将检查中有多少行匹配sometimes
. 任何值,除了1
表示Map问题(完全不匹配或多个匹配)。您可以生成摘要报告。假设您想要
a
在b中有适当的1-1匹配:也许你想产生三个比率: