I have the old Oracle 8 database that I am trying to get some data off but I can't quite get the query right.
In english:
I want to get All the records from TRANSACTION0, any records from TRADING_PARTNER that are equal to TRANSACTION0 and all records from DOCUMENT that a equal to TRADING_PARTNER.
Perhaps I have the join wrong because when the results should be 3 records (given the example data), i end up with 18.
I am sure its from the join of the last table (DOCUMENT) as there are 6 records in that table that are unique to the partner being querried.
Thanks for any help or suggestions.
Code:
SELECT TO_CHAR(TRANSACTION0.DOCUMENT_DATE, 'YYYY-MM') AS MyDate, TRANSACTION0.FK_TRANSMISSIONFK, TRADING_PARTNER.NAME,
TRANSACTION0.DOCUMENT_NAME, TRANSACTION0.DOCUMENT_ID, TRANSACTION0.FK_TRANSMISSIONGS1, DOCUMENT.TRANSLATOR_KEY,
DOCUMENT.TRANSLATOR_ALIAS, COUNT(DOCUMENT_ID)
FROM TRANSACTION0, TRADING_PARTNER, DOCUMENT
WHERE (TO_CHAR (DOCUMENT_DATE, 'YYYY-MM-DD')) >= '2010-03-01'
AND FK_TRANSMISSIONPRO = 'P'
AND TRANSACTION0.FK_TRANSMISSIONFK (+) = TRADING_PARTNER.APPLIC_PARTNER_COD
AND TRADING_PARTNER.APPLIC_PARTNER_COD (+) = DOCUMENT.FK_TRADING_PARTAPP
AND TRANSACTION0.FK_TRANSMISSIONFK = '006173082'
GROUP BY TO_CHAR(TRANSACTION0.DOCUMENT_DATE, 'YYYY-MM'), TRANSACTION0.FK_TRANSMISSIONFK, TRANSACTION0.DOCUMENT_NAME,
TRANSACTION0.DOCUMENT_ID, TRANSACTION0.FK_TRANSMISSIONGS1, TRADING_PARTNER.NAME, DOCUMENT.TRANSLATOR_KEY, DOCUMENT.TRANSLATOR_ALIAS
ORDER BY TRADING_PARTNER.NAME
In english:
I want to get All the records from TRANSACTION0, any records from TRADING_PARTNER that are equal to TRANSACTION0 and all records from DOCUMENT that a equal to TRADING_PARTNER.
Perhaps I have the join wrong because when the results should be 3 records (given the example data), i end up with 18.
I am sure its from the join of the last table (DOCUMENT) as there are 6 records in that table that are unique to the partner being querried.
Thanks for any help or suggestions.