表更新 [英] Table update
问题描述
先生在使用sqlserver时,我有这个数据
我想像这样更新TIK列
$
公式:
如果发现tik = 1那么它的重量是375 b
现在375-25 = 350 >
更新table_1设置tik = 1,其中权重350,375左右b
请帮助
Sir while using sqlserver, I have this data
I want to update TIK column as like this
Formula:
If found tik=1 then it pick up weight that is 375
Now 375-25=350
Update table_1 set tik= 1 where weight between 350,375
Please help
tqmd
表格必须只根据First TIK + ID更新一次
Table must be updated only once based on First TIK+ID
第一个TIK的ID是6
The ID of first TIK is 6
推荐答案
抱歉无法立即测试
声明@ w int =(从tbl中选择前1个权重,其中tik = 1个顺序按重量 desc)
declare @w int =(select top 1 weight from tbl where tik=1 order by weight desc)
更新table_1设置tik = 1,其中权重> = @ w-25和 重量
< @w
Update table_1 set tik= 1 where weight >=@w-25 and weight <@w
这篇关于表更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!