不是用
select distinct a,b,c 就可以吧?
如果遇到同时有a,b相同或b,c相同怎么办?

解决方案 »

  1.   

    感觉就是select distinct a,b,c from table_name
      

  2.   

    这样不行,返回的是(a,b,c)的不同组合。
      

  3.   

    就是说,不论是A,还是B,还是C 在取出的结果中绝对不重复。是不是?
      

  4.   

    select top 1 * into #t from tab1
    while exists(select 1 from tab1 a,#t b where a.a<>b.a and a.b<>b.b and a.c<>c.c
    insert #t select top 1 a.* from tab1 a,#t b where a.a<>b.a and a.b<>b.b and a.c<>c.cselect * from #t
      

  5.   

    想了想,上面是错的。
    select top 1 * into #t from tab1while exists(select 1  
                 from tab1 
                 where a not in (select a from #t) 
                 and b not in (select b from #t) 
                 and c not in (select c from #t))insert #t select top 1 * 
              from tab1 
              where a not in (select a from #t) 
              and b not in (select b from #t) 
              and c not in (select c from #t)   select * from #t
      

  6.   

    不明白你在说什么select distinct a,b,c from [tablename]不能满足你的需求?