0
這裏是我的表 更新兩列由同一表下一行的另一列在SQL
我想未來Update_date,Update_time
更新closed_date,time
爲new_class_desc ='FLM'
但如果new_class_desc
是'FollowupComments'
則忽略它並更新下一個日期爲Closed_date
我試圖查詢有點像這樣..
;WITH cte as(
SELECT *
,row_number() OVER(ORDER BY Update_date,Update_time) rn
FROM Table
WHERE Problem_sid = 1435819
)
UPDATE c1 SET Closed_date = c2.Update_date, Closed_time = c2.Update_time
FROM cte c1
JOIN cte c2 ON c1.rn = c2.rn - 1
AND c1.New_class_desc = 'FLM'
AND c2.New_class_desc <> 'FLM'
AND c2.New_class_desc not in ('FollowUpComments')
但是在這個我沒有得到new_class_desc =Bank
更新日期爲Closed_date
Flm。
請在這裏指導。