我想更新每个团队第一行之后的所有行。
TableName:测试
ID , Team , StartTime, EndTime, TotalTime
1....... A.........18:00.........20:00..........2:00
2....... B.........18:00.........20:00..........2:00
3........A.........18:00.........20:00..........2:00
4........F.........18:00.........20:00..........2:00
5........B.........18:00.........20:00..........2:00
UPDATE TEST SET StartTime = DateAdd(SECOND, - ProjectedTime * 60, EndTime)
所以在这里,我想更新第3行和第5行(因为它们不是基于团队的第一个记录)
我如何实现这一目标?
答案 0 :(得分:0)
您可以使用CTE。
with cte as
(
select test.*, row_number() over (partition by team order by ID) as teamRowNum
from TEST
)
UPDATE cte SET StartDate = DateAdd(SECOND, - ProjectedTime * 60, EndDate)
where teamRowNum > 1
答案 1 :(得分:0)
您可以将CTE与git remote set-url https://my_git_username:my_super_secret_password@git_server/repo.git
:
row_number()