select 
    distinct a.证件 
from 
    表 a 
where 
    exists(select 1 from 表 where 证件 = a.证件 and 机构 != a.机构)

解决方案 »

  1.   

    create table 表(
    机构   varchar(20),               
    证件   varchar(10))insert into 表 select '兰州营业部','110301'
    insert into 表 select '滁州营业部','110302'
    insert into 表 select '滁州营业部','110303'
    insert into 表 select '上海营业部','110301'
    insert into 表 select '上海营业部','110302'select 
        distinct a.证件 
    from 
        表 a 
    where 
        exists(select 1 from 表 where 证件 = a.证件 and 机构 != a.机构)
    --结果
    /*
    证件
    ------
    110301
    110302
    */
      

  2.   

    select 证件 from 表 group by 证件 having count(distinct 机构)>1
      

  3.   

    直接这样就可以吧。select 证件 from 表 group by 证件 having count(机构)>1