2013-10-11 228 views
0

我對DB2非常陌生。我有一個選擇查詢,我需要轉換成更新語句。查詢是這樣的:DB2 Update語句

SELECT GUID,seq original_seq_no, ROW_NUMBER() 
OVER (PARTITION BY GUID ORDER BY seq) AS new_seq_no 
FROM CHK_SEQ; 

此選擇查詢適用於MSSQl和Oracle,但不能確定與DB2。任何人都可以幫助我嗎?

+0

你無法測試它嗎? – WarrenT

回答

0

此選擇也適用於DB2。即

WITH CHK_SEQ (GUID, seq, original_seq_no) AS (VALUES 
    ('guid1', 100, 1001), 
    ('guid2', 200, 1002), 
    ('guid3', 300, 1003) 
) 
SELECT GUID,seq, original_seq_no, ROW_NUMBER() 
OVER (PARTITION BY GUID ORDER BY seq) AS new_seq_no 
FROM CHK_SEQ; 

你想如何將它轉換成更新語句?