我数据库表如下
      ID     字段1      字段2
      1       a              
      2       b   →   (a+b+c)/3  
      3       c   →   (b+c+d)/3 
      4       d   →   (c+d+e)/3 
      5       e   →     .....
      .       .          .....
把相邻2个记录求平均值后放在字段2中生成新记录
各位高手,我是初学者,还请指点。
请给出详细的语句代码,谢谢。
     

解决方案 »

  1.   

    没有直接实现这种目的的SQL语句,只能按楼上的方式来实现。LZ最终要实现的功能是什么?
      

  2.   

    字段1是采集的即时数据,由于波动较大,想把它整理。字段1的数据和一个时间信号通过
    picture1.PSet(时间信号,字段1)画了根曲线,由于字段1波动大曲线毛刺多,想把数据整理后重画曲线过滤掉多余的毛刺,相当于滤波效果。可能还有很好的方法,请大侠指点
      

  3.   

    select [id],name,
    isnull(name+(select  name from #1 where id=bbb.id-1)+(select name from #1 where id=bbb.id+1),'')/3
    from #1 bbb
      

  4.   

    create table #1 (id int ,name int)
    insert into #1
    select 1,1 union all
    select 2,2 union all
    select 3, 3 union all
    select 4,4  union all
    select 5,5select [id],name,
    isnull(name+(select  name from #1 where id=bbb.id-1)+(select name from #1 where id=bbb.id+1),'')/3
    from #1 bbb
      

  5.   

    在那个贴里已经回了你试试这个:
    用自连接select a.ID,a.字段1,a.字段2=(a.字段1+b.字段1+c.字段1)/3 from  表名 a, 表名 b, 表名 cwhere a.ID=b.ID+1 and a.ID=c.ID-1
    ---------
    随手写的,你自己调试吧