I need to SUM unique values from a table (get the distributed part payment to the invoice per PO)
I need to get only the amount paid per PO, and Invoice, if two Po or invoices match numbers I get the total amount paid without distiction, and if i go to the payment history table to retrieve information I keep adding duplicates, sorry, probably this is relatively easy but I a new at Sql..Thanks in advance
TABLE 1
AP_PAYMENT_HIST_DISTS (Amount paid)
TABLE 2 AP_INVOICE_PAYMENTS_ALL (Total Invoice amont)
And my query
SELECT
dst.organization_code AS destination_organization,
-- Datos del pago
TO_CHAR(pmt.payment_date, 'DD/MM/YYYY') AS payment_date,
chk.check_number AS payment_number,