Click here to Skip to main content
15,882,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

 
Share this answer
 
U can do this by query but it is batter if u use stored procedure because u have to use join and sub-query which create query very complex.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900