如果是固定(已知)的,可以用DeCode,否则的话处理起来就比较麻烦

解决方案 »

  1.   

    使用decode进行行列转换知适用于字段的取值情况很少的情况,否则不可行。
    我没有听说有这样的命令,可以随意的将行转为列。
      

  2.   

    select max(decode(id,1,name)) f1,max(decode(id,2,name))f2,max(decode(id,3,name))f3,max(decode(id,4,name))f4
    from t_test
    union all
    select to_char(max(decode(id,1,id))) f1,to_char(max(decode(id,2,id)))f2,to_char(max(decode(id,3,id)))f3,to_char(max(decode(id,4,id)))f4
    from t_testt_test
    id       name
    1 a                                       
    2 b                                       
    3 c                                       
    4 d                                       
      

  3.   

    sum(decode()) ...group by ...
    固定用法,没有什么可发挥的了。不过还是不懂,查旧贴