記一次ORACLE查詢更新

2021-10-09 22:05:00 字數 900 閱讀 5688

結轉專案表.結轉收入 = 結轉專案表.結轉金額/(1+稅率表.稅率)

-- where條件是表名中 表名.id 在查詢結果中存在對應的值才能執行更新語句

update 表名 set 表名.欄位名=

(select

查詢結果.欄位名

from

( 查詢語句 ) 查詢結果名

where 表名.id=查詢結果.sys_id)

update ct_mrt_companyprjcarrybill cpb

set cfcarrynotaxrec =

(select

round

(cfreadycarryamount /(1

+ cfaddedtax),2

)from

(select a.fid, isnull(a.cfreadycarryamount,0)

as cfreadycarryamount,

isnull(b.cfaddedtax,0)

as cfaddedtax

from ct_mrt_companyprjcarrybill a

left

join ct_mrt_projecttaxrate b on b.cfcompany = a.cfcompany

and b.cfprojectno = a.cfprojectno

where a.cfproducttype like

'%車位%'

and a.cfsrctype =

'0') t

where cpb.fid = t.fid

)

oracle將查詢結果作為更新字段更新到其他表裡

記一次sql查詢

效果圖 要查詢出如上圖的效果 知識點.1.多表巢狀查詢.2.輸出查詢結果,group concat函式 3.關聯查詢 select t1.學校,case when t1.年級 2017 then 1年級 when t1.年級 2016 then 2年級 when t1.年級 2015 then 3年...

記一次複雜查詢

專案中有乙個需求,查出使用者取出,充值次數,金額,使用者名稱,金幣的總量和每局遊戲的盈虧等做乙個統計,而他們分布在個表中,分別是使用者表,使用者取出表,使用者充值表,每局遊戲表中。首先想到的就是要分組查詢,group by user.userid.因為有的使用者有充值記錄但不一定有取出記錄,所以需要...

記一次Mybatis更新操作使用了查詢標籤的失誤

我先寫了乙個方法 void updateuser user user 然後寫配置檔案 updateuser parametertype user update user set username address where id select 這裡犯了乙個錯誤 因為我們要執行更新操作 卻寫了查詢的標...