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]
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]
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]
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]
playwarcraft,分都给你了,希望你能好心再帮我解决一个问题!