日期:2014-05-17  浏览次数:20766 次

不用游标能解决这个问题么?
select             a.pono,b.part,a.date                 from         a     ,         b     ,     c     where        
a.pono=b.pono         and     b.part     in     ( '30804001 ', '30804003 ', '30804004 ')     and     b.part=c.part             ;    
              每一个part都有多个pono,你说我想求时间最大的那个pono,除了用游标还有别的方法没有。    
我用游标的主要步骤是这么写的   ,   :    
select     part     from     c     where     part     in     '30804001 ', '30804003 ', '30804004 ')         ;        
  open     mypur;            
          loop    
          fetch     mypur     into     as_part;        
          exit   when   mypur   %notfound;                                            
              select             pono,reldate,part,description,unit,unprc                
          from     (select         a.pono,a.date,b.part,c.description,b.unit,b.unprc     from    
                                              a     ,         b     ,             c     where        
                                      a.pono=b.pono         and     b.part=as_part     and     b.part=c.part            
                                      order     by     a.reldate     desc     )             where     rownum=1     ;                            
                  end     loop;    
             
谁有更好的方法解决速度问题,我用SQL     SERVER就是用游标作的,可oracle用游标速度太慢了!大家还有别的思想么

------解决方案--------------------
SQL> select * from t;

ID NAME NUM
---------- -------------------- ----------
1 wzk 3
2 fg 3
3 zx 4
3 cc 5
2 gg 6

SQL> select id,max(name) m_n from t grou