0

次の選択ステートメントがあります。

SELECT  projectid,documentid,revisionno,configurationid,variable45,
        ISNULL(Variable45, (SELECT TOP 1 variable45 FROM pivot_table WHERE documentid = t.documentid and projectid=t.projectid
        and configurationid=t.configurationid and cast(revisionno as int) < cast(t.revisionno as int) AND Variable45 is NOT NULL 
        ORDER BY projectid desc,documentid desc ,revisionno desc,configurationid desc)) as NewCol
FROM    pivot_table t;

次の方法で更新ステムに変換しようとしましたが、レコードの更新が間違っています。誰でも私の問題を解決するのを手伝ってもらえますか:

UPdate PIVOT_TABLE
set variable45 = ((SELECT TOP 1 variable45 FROM pivot_table t WHERE t.documentid = documentid and t.projectid=projectid
        and t.configurationid=configurationid and cast(t.revisionno as int) < cast(revisionno as int) AND Variable45 is NOT NULL 
        ORDER BY revisionno desc)) where Variable45 is NULL;

DB: SQLExpress2008。

お知らせ下さい。ありがとうございました。

4

1 に答える 1

0

OK私はそれを理解しました:

    UPdate pt
    set pt.variable45 = ((SELECT TOP 1 t.variable45 FROM pivot_table t WHERE 
t.documentid = pt.documentid and t.projectid=pt.projectid and t.configurationid=pt.configurationid and cast(t.revisionno as int) < cast(pt.revisionno as int) AND t.variable45 is NOT NULL 
            ORDER BY revisionno desc)) from PIVOT_TABLE pt where pt.variable45 is NULL;
于 2012-08-11T15:31:25.823 に答える