匹配没有身份证的人 [英] Matching people without national ID

查看:65
本文介绍了匹配没有身份证的人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将表中的人与名字,姓氏和出生日期匹配

I'm trying to match people in a table with initial, last name, and birth date

我关注了此答案,有助于减少与当前ID匹配的ID的匹配数(因此3匹配1,但1不匹配3)

I followed this answer which helps reduce the number of matches to IDs older than the current one (so 3 matches to 1 but 1 does not match to 3)

但是我有1,2和3匹配的问题,结果有
3-2
3-1
2-1

But im having the problem with 1,2 and 3 being matches, the result has
3-2
3-1
2-1

我怎样才能做到3只匹配1个?

how can i make it so 3 only matches to 1?

这是我正在使用的代码

select  *
from    
    YourTable t1
    join    YourTable t2 on t1.ID < t2.ID 
    and t1.initial= t2.initial
    and t1.lastname= t2.lastname
    and t1.birth= t2.birth

推荐答案

可能是这样的吗?

 select  t2.id, min(t1.id)
from    
    YourTable t1
    join    YourTable t2 on t1.ID < t2.ID 
    and t1.initial= t2.initial
    and t1.lastname= t2.lastname
    and t1.birth= t2.birth
group by t2.id  

这篇关于匹配没有身份证的人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆