在Oracle上使用join更新语句

时间:2019-02-07 11:13:31

标签: sql oracle

我有此查询,但它不起作用。你能告诉我解决方案吗?

update temp_msisdn_saldo 
    set saldo=(
        select sum(saldo) from (
            select a.msisdn as mdn, a.saldo from temp_msisdn_saldo a 
            union all
            select b.mdn as mdn, b.saldo from temp_msisdn_saldo_yesterday b 
        ) z
    )
where msisdn=z.mdn

1 个答案:

答案 0 :(得分:0)

您可以将其重写为:

dim rng as range

with worksheets("sheet1")
    with .range(.cells(6, "A"), .cells(.rows.count, "A").end(xlup))
        on error resume next
        set rng = .specialcells(xlCellTypeFormulas, xlLogical+xlNumbers+xlTextValues)
        on error goto -1
        if not rng is nothing then
            rng.entirerow.delete
        end if
    end with
end with

与您可以使用update temp_msisdn_saldo set saldo = ( select sum(saldo) from (select a.msisdn as mdn, a.saldo from temp_msisdn_saldo a union all select b.mdn as mdn, b.saldo from temp_msisdn_saldo_yesterday b ) z where z.mdn = temp_msisdn_saldo.msisdn ); 相同:

CTE