I having some difficulty to update a table column based on the following conditions and scenario.
EmpID Consulting-A Consulting-B Consulting-C A1 0 10 20 A2 50 30 0 A3 0 0 70
EmpID Consulting-A Consulting-B Consulting-C A1 10000 20000 30000 A2 0 35000 15000 A3 0 8000 0
EmpID [Total Valid Consulting] A1 20000 + 30000 = 50000 A2 0 + 35000 = 35000 A3 0
At the end of the day, I want to have the
Total Valid Consulting having the sum of
Data Table when it has value greater than zero in the
For example, the
Total Valid Consulting for
EmpId A1 is only
Consulting-B + Consulting-C (from
Data Table) since in the
Condition Table the
EmpID A1 only have
Consulting-C value of greater than zero.
So I want to add only the columns data that has the value from the other table that are greater than zero. Is there a way to do so in SQL Server? This is for my update statement that I'm having issue to come up with.
Appreciate any help and advice. Thanks!