a       b       c
1 2 3
1 2 3
如何转为 
1 1
2 2
3 3

解决方案 »

  1.   

    一个sql无法实现,一个思路是再建一张表a,通过存储过程把数据转为到a中。实现也不难。效率还高。
      

  2.   

    select decode(A,'1',1),A 
    from (
    select '1' A,'2' B,'3' C from dual
    union all 
    select '1' A,'2' B,'3' C from dual)
    union 
    select decode(B,'2',2),B 
    from (
    select '1' A,'2' B,'3' C from dual
    union all 
    select '1' A,'2' B,'3' C from dual)
    union 
    select decode(C,'3',3),C 
    from (
    select '1' A,'2' B,'3' C from dual
    union all 
    select '1' A,'2' B,'3' C from dual)
      

  3.   

    with t1 as
    (
    select '1' A,'2' B,'3' C from dual
    union all 
    select '1' A,'2' B,'3' C from dual)
    select decode(A,'1',1),A from t1
    Union 
    select decode(B,'2',2),B from t1
    union 
    select decode(C,'3',3),C from t1这两个结果都一样的