Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

JOIN

$
0
0

UPDATE ARH SET [OPEN] = 'TRUE', CLOSEDATE = NULL, PAID = ARH.PAID - NEW.AMOUNT FROM
(SELECT INVOICE, AMOUNT FROM CREDITMEMO WHERE CINVOICE = 113202)NEW JOIN ARH ON ARH.INVOICE=
NEW.INVOICE

This query updates the information based on the subquery, but if the subquery gives a result like so

Invoice     Amount

113201311.91
113272200.00
113201100.00

since there are 2 invoices with the same number, and it doesn't join twice it will only change the amount in the ARH table to be paid minus the first time the amount shows for this invoice so if paid = 500 it will be 500 - 311.91 and not 500 - 311.91 and then 188.09 -100 which is what I would like it to be. 

How can I make sure it works? 



Debra has a question


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>