select distinct * from tablename a,tablename b
where a.col<b.col

解决方案 »

  1.   

    select distinct a.col as col1,b.col as col2 from tablename a,tablename b
    where a.col<b.col
      

  2.   

    declare @t table 
    (
    id varchar(10)
    )insert into @t select 'a' union all select 'b' union all select 'c' union all select 'd' select *from @t a join @t b on a.id <b.id 
    order by a.id id         id         
    ---------- ---------- 
    a          b
    a          c
    a          d
    b          c
    b          d
    c          d(所影响的行数为 6 行)
      

  3.   

    直接这样就行了  select a.a,b.a from @a a, @a b  where a.a<b.a  order by a.a