首页 新闻 会员 周边

查找重复的结果

0
悬赏园豆:30 [已关闭问题] 关闭于 2010-07-22 09:46

bsc cell
LZ2 ML01
LZ2 ML01
LZ2 ML02
LZ2 ML03
LZ3 ML07
LZ3 ML01
LZ4 ML10
LZ5 ML02

查找重复的CELL ,同一个BSC不显示
想要结果
bsc cell
LZ2 ML01
LZ3 ML01
LZ5 ML02
LZ2 ML02

小权的主页 小权 | 初学一级 | 园豆:10
提问于:2010-07-21 15:46
< >
分享
所有回答(2)
0
select * from Table a
where a.cell in (select b.cell from Table b)

 

 上面的是错误的,正确的:

 

select * from Table a
whereselect count(*) from Table b where b.cell=a.cell)>1

 

 

kyo-yo | 园豆:5587 (大侠五级) | 2010-07-21 16:05
你这样是全部查出来。。。
支持(0) 反对(0) 小权 | 园豆:10 (初学一级) | 2010-07-21 16:15
不好意思。。和我另外一个东西搞混了,应该是 select * from Table a where (select count(*) from Table b where b.cell=a.cell)>1
支持(0) 反对(0) kyo-yo | 园豆:5587 (大侠五级) | 2010-07-21 19:50
@顾磊(kyo-yo):你这个包含重复的
支持(0) 反对(0) dege301 | 园豆:2825 (老鸟四级) | 2010-07-21 20:26
@dege301:诶。的确,不好意思了,是应该加个distinct,因为"查找重复的CELL ,同一个BSC不显示"..是我理解错误
支持(0) 反对(0) kyo-yo | 园豆:5587 (大侠五级) | 2010-07-22 09:28
其实也是错了。今天突然想到了 select distinct bsc,cell from XX where cell in (select cell from(select distinct(cell),bsc from XX) as t group by cell having count(*) >1)
支持(0) 反对(0) 小权 | 园豆:10 (初学一级) | 2010-07-22 09:44
0

select distinct bsc,cell from xx a where (select count(*) from xx b where b.cell=a.cell )>1

dege301 | 园豆:2825 (老鸟四级) | 2010-07-21 20:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册