小弟是个初学者,望各位大虾不吝赐教,在Oracle7中如何编写交叉查询?
最好有源码。谢谢了!

解决方案 »

  1.   

    举例说明:
    表 EmpWage
     wid empid eyear  emonth emoney
      0   1001  2002  1       600
      1   1001  2002  2       600
      2   1001  2002  3       700
      3   1001  2002  4       650
    ...
    得到的结果
     empid   1月   2月    3月   4月
      1001  600   600    700   650
      1002  ...
      

  2.   

    select empid,sum(m1),sum(m2),...sum(m12) from (
    select empid,decode(emonth,'1',emoney,0) m1,decode(emonth,'2',emoney,0) m2,decode(emonth,'3',0) m3...decode(emonth,'12',0) m12 from empwage)
    group by empid;
      

  3.   

    就是行列转换呀。BZSZP写的应该可以,主要是利用DECODE函数的功能。