omacron
Technical User
- Feb 5, 2002
- 149
I am trying to write a update script and having some problems. Let me show you the an example;
Data;
Now what I need to do is update a Customer table with the payments. So this what the results should be;
I am really not sure where to start for this. I know how to do the update if it wasn't a sum;
Thanks for the help
Data;
Code:
Table: Payments
CustName Amount
Bob 10.00
Bob 45.00
Sam 5.00
Sam 85.00
Bob 20.00
Now what I need to do is update a Customer table with the payments. So this what the results should be;
Code:
Table: Customer
CustName Payment
Bob 75.00
Sam 90.00
I am really not sure where to start for this. I know how to do the update if it wasn't a sum;
Code:
update Customer
set Customer.Payment = P.Amount
from Customer C
inner join Payments P
on P.CustName = C.CustName
Thanks for the help