解决方案 »

  1.   

    百度一下“oracle行转列”,一堆你要的答案
      

  2.   

    呵呵,参考这个:
    http://blog.csdn.net/dyccsxg/article/details/10833953
    http://bbs.csdn.net/topics/390574842
      

  3.   

    这是case when 语句的基本语法
      

  4.   


    with temp as (
    select '1' 项次, '项目1' 项目, 'x0001' 文号 from dual union all
    select '1' 项次, '项目2' 项目, 'x0002' 文号 from dual union all
    select '2' 项次, '项目1' 项目, 'x0003' 文号 from dual union all
    select '2' 项次, '项目3' 项目, 'x0004' 文号 from dual
    )
    select  项次,
            max(case when 项目='项目1' then  文号 else null end) 项目1,
            max(case when 项目='项目2' then  文号 else null end) 项目2,
            max(case when 项目='项目3' then  文号 else null end) 项目3
    from temp         
    group by 项次