字段1  字段2   字段3 
1       2       4
ff      dd      xx如上面的例子,如何做查询 让两行中的字段进行相加。如 相加的结果 如  1ff,2dd,4xx 

解决方案 »

  1.   

    --> 测试数据: @tb
    declare @tb table (字段1 varchar(2),字段2 varchar(2),字段3 varchar(2))
    insert into @tb
    select '1','2','4' union all
    select 'ff','dd','xx'select *,id=identity(int,1,1) into #t from @tbselect col1=a.字段1+b.字段1,
       col2=a.字段2+b.字段2,
       col3=a.字段3+b.字段3
    from 
    #t a,#t b
    where 
    a.id=b.id-1  --------------------------------------
    col1 col2 col3
    ---- ---- ----
    1ff  2dd  4xx(1 行受影响)drop table #t