取出t1表中a字段连续5天不为0的平均值!~~
这样的语句应该怎么写呀!~~~~

解决方案 »

  1.   

    一个语句怕是有困难,用procedure或者function吧
      

  2.   

    t1表   rq            字段a
    20050102           3
    20050104           0
    20050105           22
    20050106           33
    20050107           1
    20050108           33
    20050109           1要求就是求出字段a连续五天不为0时的平均值
      

  3.   

    没仔细试,  
    select a.unique_id,sum(a.all_points) from  a, b
      where a.rq <=b.rq +5
      group by a.unique_id 
      having sum(a.字段a) >0
      

  4.   

    没仔细试,  
    select a.unique_id,sum(a.all_points) from  a,a b
      where a.rq <=b.rq +5
      group by a.unique_id 
      having sum(a.字段a) >0
      

  5.   

    select sum(a)/5 from (select * from table order by to_number(rq) where a!=0) where rownum<6
    大致是这个思路