请问一个简单有关问题,多谢

请教一个简单问题,谢谢
本帖最后由 hzg98 于 2013-03-22 09:52:12 编辑
原表

本局 对端局向 光缆容量
阿什 大长屯 48芯
阿什 孟家 48芯
阿什 江南 96芯
大长屯 阿什 48芯
孟家 阿什 48芯
江南 阿什 96芯
江南 平山 144芯
平山 江南 144芯
平山 江南 96芯
河南街 平山 24芯

要求得到

a端 b端 光缆容量
大长屯 阿什 48芯
孟家 阿什 48芯
江南 阿什 96芯
江南 平山 144芯
平山 江南 96芯
河南街 平山 24芯

目的就是去重,比如“大长屯-阿什 48芯”其实和“阿什-大长屯 48芯”是一个东西,要求去掉一个,谢谢!

------解决方案--------------------
这个就是常见得排除重复行嘛
use tempdb 
go
declare @tb table(id int identity(1,1),col1 varchar(10))
insert into @tb (col1)
select 'A' union all
select 'A' union all
select 'B' union all
select 'B' union all
select 'B' union all
select 'C' 

select * from @tb
where id  in
 (
select max(id) from @tb
group by col1
)
你根据你得需求改改就成

------解决方案--------------------
create table t_t (seqno int,fa varchar(20),fb varchar(20),fc varchar(20) )
insert into t_t values(1,'阿什','大长屯','48芯')
insert into t_t values(2,'阿什','孟家','48芯')
insert into t_t values(3,'阿什','江南','96芯')
insert into t_t values(4,'大长屯','阿什','48芯')
insert into t_t values(5,'孟家','阿什','48芯')
insert into t_t values(6,'江南','阿什','96芯')
insert into t_t values(7,'江南','平山','144芯')
insert into t_t values(8,'平山','江南','144芯')
insert into t_t values(9,'平山','江南','96芯')
insert into t_t values(10,'河南街','平山','24芯')

select * from t_t a where not exists( select 1 from t_t b where 
( (a.fb=b.fa and a.fc=b.fc ) or (a.fa=b.fb and a.fc=b.fc) ) and a.seqno<b.seqno )