Can anybody explain why when running an update query, only one record is updated where there is a match in the join and not updated by all of the matches ?
I have a table that is being updated by the value of another table where they match account numbers.
The join is on account numbers and the table that has the values has multiple records with the same account number but only the first records value is updated ???
Code:
Update tblHist
Set Balance = Balance + A.Amount
From tblHist H
Inner join Adjustments A
On H.Accountnumber = A.Accountnumber
This will only update the accountnumber record in the history table with the first record that contains the same account number from the adjustments table (there are several matching account numbers)
Thanks
Group by h.accountnumber, t.accountnumber, amount
I have a table that is being updated by the value of another table where they match account numbers.
The join is on account numbers and the table that has the values has multiple records with the same account number but only the first records value is updated ???
Code:
Update tblHist
Set Balance = Balance + A.Amount
From tblHist H
Inner join Adjustments A
On H.Accountnumber = A.Accountnumber
This will only update the accountnumber record in the history table with the first record that contains the same account number from the adjustments table (there are several matching account numbers)
Thanks
Group by h.accountnumber, t.accountnumber, amount