原始数据库为:
rq           bm      sl
2001-1-1     bm1      1
2001-1-2     bm2      2
2001-1-3     bm1      2
2001-1-10    bm1      2
2001-1-12    bm2      1
假设2号为周一,现在要求按周总结数据:
rq           bm      sl
2001-1-1     bm1      1 
2001-1-2     bm2      2      
2001-1-2     bm1      2
2001-1-9     bm1      2
2001-1-9     bm2      1
即把日期改为所在周的周一的日期.
数据大概有3000条,我用adotable逐条修改实现,但速度太慢,无法忍受。
求速度快的算法。

解决方案 »

  1.   

    直接使用SQL Server语句吧~~
      

  2.   

    我就是想知道用sql语句怎样实现。
    急!!!
      

  3.   

    Update Table1 Set f = DateAdd(dd, 0-DatePart(dw, f)+2, f) From Table1测试通过!!!不过要注意 你的SQL Server的FirstDate的值是多少!
      

  4.   

    hansome(连环):还是用adotable改写?而且实现不知道有多少个prod,也就是不知道1号的数据会有几个,2号的数据会有几个。
      

  5.   

    The weekday (dw) datepart returns a number that corresponds to the day of the week, for example: Sunday = 1, Saturday = 7. The number produced by the weekday datepart depends on the value set by SET DATEFIRST, which sets the first day of the week.
      

  6.   

    weekday这个函数我知道阿,但是我不知道怎样用sql语句配合这个函数解决这个问题阿。
      

  7.   

    Update Table1 Set f = DateAdd(dd, 0-DatePart(dw, f)+2, f) From Table1
    这里各个参数都是什么?可以说清楚点么?
      

  8.   

    这就是SQL语句!!!看不出来??!Update Table1 Set f = DateAdd(dd, 0-DatePart(dw, f)+2, f) From Table1Table1 <-----表名
    f <--------日期型字段!!
      

  9.   

    dd,dw是什么意思?0-DatePart是什么意思?
      

  10.   

    dd,dw是什么意思?0-DatePart是什么意思?
    如果是按月和按年统计呢?