select
distinct a.证件
from
表 a
where
exists(select 1 from 表 where 证件 = a.证件 and 机构 != a.机构)
distinct a.证件
from
表 a
where
exists(select 1 from 表 where 证件 = a.证件 and 机构 != a.机构)
解决方案 »
- 求救高人
- 那位给分析一下
- SQL server 2005安装应用(请高手帮忙)
- 关于存储过程传入 一个参数 然后用 where cc in (@tt) 删除数据
- 如何一次性显示出 某一层下所有子节点 返回表
- 请教一个sql语句
- 求助,关于Navicat连接SLQ2000的问题。在线等!!!
- SQL2000索引问题,请高手指点。
- sql中创建一个表,设置两列role_id和func_id为联合主键的语句是什么?谢谢!
- 查询结果有重复,请高手们指点,谢谢了!!!
- 怎样在某个字段前(后)插入一个字段?
- 急请问 怎么知道表'AA'中是否存在一个约束 ? 如果存在就删除它,再新建一个约束,用SQL语句怎么实现??
机构 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
*/