# 更新一个表的多条记录，用另一个表的数据做一些计算。[英] Update multiple rows of a table with some calculation done with data from another table .

### 问题描述

ECodeCountyGroupnameProjectnameWorktype持续时间
101NYProj1WT110
101NYProj2WT220
102NPProj1WT120
101NPProj3WT310
102NKProj1WT120

NonProd
ECodeCountyGroupName持续时间
101NY10
102NP10
103NY10

ECodeCountyGroupname持续时间
101NY30
101NP35
102ND35
103纽约40
104GP45

Set Duration= (公式为:- Filtered.Duration * NonProd.Duration)/Prod.Duration when

()

## 推荐答案

### 问题描述

I have 3 table and my requirement is to update few records of a table(Using mathematical formula) with refence of the another table.
Sample table and sample data are as below:-

Filtered

ECodeCountyGroupnameProjectnameWorktypeDuration
101NYProj1WT110
101NYProj2WT220
102NPProj1WT120
101NPProj3WT310
102NKProj1WT120

NonProd
ECodeCountyGroupNameDuration
101NY10
102NP10
103NY10

Prod
ECodeCountyGroupnameDuration
101NY30
101NP35
102ND35
103NY40
104GP45

I want to update the "Filtered" Table Column Name is "Duration" as per the condition that:-
Update Filtered
Set Duration= (Formula will be:- Filtered.Duration * NonProd.Duration)/Prod.Duration when
Condition 1: Filtered.CountyGroupname=NonProd.CountyGroupname=Prod.CountyGroupName
Condition 2: Filtered.Ecode=NonProd.Ecode=Prod.ECode
where exists
()

Note:- As per the logic only first 3 Rows Of the duration in "Filtered Table" got updated.Rest of the field will not be changed.

## 推荐答案

Hi,

use update with joins