嗨,我有一個複雜的條件。我有一個表可以說「測試」根據當前行選擇完整的下一行
ID Partner Type Amount
143854 CSTC Purchase -0.81
144029 CSTC Purchase -0.69
144030 CSTC Purchase -1.33
144031 CSTC Purchase -0.47
144032 CSTC Purchase -1.8
149527 CSTC div 1574.48
149528 CSTC Purchase -1574.48
149531 CSTC div 867.53
149532 CSTC Purchase -867.53
149539 CSTC div 76.2
149540 CSTC Purchase -76.2
149550 CSTC div 8.77
149551 CSTC Purchase -8.77
149554 CSTC div 700.45
149555 CSTC Purchase -700.45
我想刪除其類型=「格」和下一行的行應該有類型=「購買」
也就是說,如果type = 'div'
的每次出現和下一行type = 'Purchase'
刪除其他兩個我想對type = 'div'
行執行一些更新操作。
我已經試過領導我可以得到下一行輸入col值,但它沒有幫助。
select LEAD([Type]) OVER (ORDER BY ID) Next, ID, Partner,[Type],Amount from Test where date='9/18/2014' and ([Type] = 'div' or [Type] = 'Purchase')
sql server 2008 does not科技支撐LEAD() – 2014-09-24 08:06:21
我已經與SQL Server 2012 – 2014-09-24 08:06:36
嘗試過,但,這不是你如何標記問題... – 2014-09-24 08:06:53