[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Duplicate Records from 2 tables



begin-SELECT
INVOICE_ID,      ! comma is optional here
INVOICE_DT,      ! comma is optional here
GROSS_AMT
    move &INVOICE_ID to $INVOICE_ID
    move &INVOICE_DT to $INVOICE_DT
    move &GROSS_AMT  to #GROSS_AMT
    move 'N' to $FOUND
    do Get-Voucher-Information
    if $FOUND = 'Y'
        print ' '    (+1,1)
    end-if
FROM PS_VOUCHER
GROUP BY INVOICE_ID, INVOICE_DT, GROSS_AMT
HAVING COUNT(*) > 1
UNION
SELECT       ! SELECT REQUIRED
INVOICE_ID,      ! comma is REQUIRED here
INVOICE_DT,      ! comma is REQUIRED here
GROSS_AMT
FROM PS_VOUCHER_HIST
GROUP BY INVOICE_ID, INVOICE_DT, GROSS_AMT
HAVING COUNT(*) > 1
UNION
SELECT       ! SELECT REQUIRED
A.INVOICE_ID,      ! comma is REQUIRED here
A.INVOICE_DT,      ! comma is REQUIRED here
A.GROSS_AMT
FROM PS_VOUCHER A, PS_VOUCHER_HIST B
WHERE A.INVOICE_ID = B.INVOICE_ID AND
   A.INVOICE_DT = B.INVOICE_DT AND
   A.GROSS_AMT = B.GROSS_AMT
end-select