本帖最后由 ndsc1qqqqqq 于 2012-04-12 17:25:07 编辑

解决方案 »

  1.   

    这叫啥需求啊。最终展示结果?
    sbid列只有1、2、3内容?还有4、5、6 不。要是不固定,没得玩了。
      

  2.   

    select 'abmc' "sbid",
    max(decode(sbid,1,sbmc,null) )"1",
    max(decode(sbid,2,sbmc,null) )"2",
    max(decode(sbid,3,sbmc,null) )"3"
    from code 
    union
    select 'zt1' "sbid",
    max(decode(sbid,1,zt1,null) )"1",
    max(decode(sbid,2,zt1,null) )"2",
    max(decode(sbid,3,zt1,null) )"3"
    from code
    union
    select 'zt2' "sbid",
    max(decode(sbid,1,zt2,null) )"1",
    max(decode(sbid,2,zt2,null) )"2",
    max(decode(sbid,3,zt2,null) )"3"
    from code
    union
    select 'zt3' "sbid",
    max(decode(sbid,1,zt3,null) )"1",
    max(decode(sbid,2,zt3,null) )"2",
    max(decode(sbid,3,zt3,null) )"3"
    from code
      

  3.   

    前提是所有列的数据形式都为varchar2
      

  4.   


    都是varchar2的?  Data和number字段该如何处理呢?