本帖最后由 HardlyStudy 于 2010-06-07 15:31:10 编辑

解决方案 »

  1.   

    declare @m int,@mm int,@mmm int
    select @m=[M1],@mm=[MM2],@mmm=[MMM3]  from T where [F1] is nullselect [F1],[M1] as Amt,@m as MCode from T where [M1] is not null
    union all
    select [F1],[MM2] as Amt,@mm as MCode from T where [MM2] is not null
    union all
    select [F1],[MMM3] as Amt,@mmm as MCode from T where [MMM3] is not null
    order by [F1]
      

  2.   


    declare @m int,@mm int,@mmm int
    select @m=[M1],@mm=[MM2],@mmm=[MMM3] from T where [F1] is nullselect [F1],[M1] as Amt,@m as MCode from T where [F1] is not null and [M1] is not null
    union all
    select [F1],[MM2] as Amt,@mm as MCode from T where [F1] is not null and [MM2] is not null
    union all
    select [F1],[MMM3] as Amt,@mmm as MCode from T where [F1] is not null and [MMM3] is not null
    order by [F1]
      

  3.   

    哦,明白你们的意思了,看来只能一列一列的操作,实际的MCode不只三列,有一二十列。晕死。慢慢搞吧。
      

  4.   

    千分散尽还复来......
    playwarcraft,分都给你了,希望你能好心再帮我解决一个问题!