有一个表T1  
 编号       A               B             C  
  1           10             12           14  
  2           11               0           13  
  ....要用一个Sql语句将它化为 
  编号     类型         数量      
  1             A               10  
  1             B               12  
  1             C               14  
  2             A               11  
  2             C               13  
  ....  
   
 多谢!!

解决方案 »

  1.   

    select 编号,'A',A 数量 from T1 where A<>0 union all
    select 编号,'B',B 数量 from T1 where B<>0 union all
    select 编号,'C',C 数量 from T1 where C<>0
    order by 1,2
      

  2.   

    select 编号,'A' 类型,A 数量 from T1 where A <>0 union all 
    select 编号,'B' 类型,B 数量 from T1 where B <>0 union all 
    select 编号,'C' 类型,C 数量 from T1 where C <>0 
    order by 1,2