表1
F_flag F_bookdate F_zhou
0 2006-06-04 2
0 2006-06-05 2
0 2006-06-04 2
0 2006-06-05 2把满足条件 (当前日期-F_bookdate)整除F_zhou 的F_flag的值变为1
这SQL语句怎么写啊?
F_flag F_bookdate F_zhou
0 2006-06-04 2
0 2006-06-05 2
0 2006-06-04 2
0 2006-06-05 2把满足条件 (当前日期-F_bookdate)整除F_zhou 的F_flag的值变为1
这SQL语句怎么写啊?
F_flag F_bookdate F_zhou
1 2006-06-04 2
0 2006-06-05 2
1 2006-06-04 2
0 2006-06-05 2
insert into @t select 0,'2006-06-04',2
union all select 0,'2006-06-05',2
union all select 0,'2006-06-04',2
union all select 0,'2006-06-05',2update @t set F_flag=1 where datediff(day,F_bookdate,getdate())%F_zhou=0select * from @t--这样?
表1
F_flag F_bookdate F_zhou
1 2006-06-04 2
0 2006-06-05 2
1 2006-06-04 2
0 2006-06-05 2那么 用 当前的日期-F_bookdate整除F_zhou也就是 (2006-06-04-2006-06-04)整除2=0
如果 (2006-06-04-2006-06-05)整除2=-0.5(不是整数不满足条件)把满足这条件的记录的F_Flag改为1