我用的是ACCESS一张表 有很多字段 里边有数据 现在要求其中五个字段: 身份证号 收据编号 协议编号 金额 姓名, 五项有2项数据相同 就查询显示出来请问这个SQL语句怎么写呢? 求指教 谢谢

解决方案 »

  1.   

    我知道access是用IF来判断,我写个case when的判断,你自己更改
    假设还有个字段ID记录不同的记录(行号)
    select m.* from
    (
    select case when t1.身份证号 = t2.身份证号 then 1 else 0 end +
           case when t1.收据编号 = t2.收据编号 then 1 else 0 end +
           case when t1.协议编号 = t2.协议编号 then 1 else 0 end +
           case when t1.金额 = t2.金额 then 1 else 0 end +
           case when t1.姓名 = t2.姓名 then 1 else 0 end cnt
    from tb t1 , tb t2
    where t1.id <> t2.id
    ) m
    where cnt >= 2此问题在这里有个类似的.
    http://topic.csdn.net/u/20111029/16/4e23cb0b-dccd-4323-b318-9e147a95c81a.html