“SELECT a.internal_invoice_no FROM MAN_SUPP_INVOICE a
INNER JOIN GEN_LED_VOUCHER_ROW_QRY b
ON b.COMPANY = a.COMPANY WHERE a.internal_invoice_no = SOMEVALUE“
in SQL developer it retrieves one value in many rows.
Hi @Ed22
The COMPANY column alone is not enough to uniquely identify the correct row in GEN_LED_VOUCHER_ROW_QRY
. If there are several rows in GEN_LED_VOUCHER_ROW_QRY
with the same COMPANY value, they will all match to the same record in MAN_SUPP_INVOICE
, causing duplicate rows in the result.
To avoid multiple matches, you may need to join on additional columns (like OBJKEY, INVOICE_ID, VOUCHER_NO, or other keys) that uniquely identify rows.
SELECT a.internal_invoice_no
FROM MAN_SUPP_INVOICE a
INNER JOIN GEN_LED_VOUCHER_ROW_QRY b
ON a.COMPANY = b.COMPANY
AND a.OBJKEY = b.OBJKEY -- or use another relevant column to uniquely join the tables
WHERE a.internal_invoice_no = 'SOMEVALUE';
If you are sure that you only need unique internal_invoice_no values and don't care about other columns, you can use DISTINCT
to eliminate duplicate rows.
SELECT DISTINCT a.internal_invoice_no
FROM MAN_SUPP_INVOICE a
INNER JOIN GEN_LED_VOUCHER_ROW_QRY b
ON b.COMPANY = a.COMPANY
WHERE a.internal_invoice_no = 'SOMEVALUE';
I believe the issue arises because the COMPANY column alone is not sufficient to uniquely match the rows in both tables. Adding more specific join conditions or using DISTINCT
would help solve your issue.
Regards,
Chanuka