j2911
asked on
Code Help
First Part of my issue:
I have written the following code to view the results seen in the attached report called: .xls. What I am having a problem with is I cannot include the records for “RightScenarioMissing” found in the field STAT_CD seen in the attached First_Run_ReportTEST_ELEME NT_COMPARE _RESULT table.
Here’s the code I'm talking about:
SELECT
TECR.COMPR_RUN_ID as COMPR_RUN_ID,
left.TRAN_ID as LTRAN_ID,
right.TRAN_ID as RTRAN_ID,
left.INTFC_NM as INTFC_NM,
tecr.COMPR_RSULT_STAT_CD as STAT_CD,
left.TEST_SCNRO_ID as TEST_SCNRO_ID,
left.EXPTD_UNIQ_DESCR_VALU E_DESC as TRACKING_NR_LEFT,
right.EXPTD_UNIQ_DESCR_VAL UE_DESC as TRACKING_NR_RIGHT
FROM
TEST_ELEMENT_COMPARE_RESUL T tecr, TEST_SET_ELEMENT LEFT, TEST_SET_ELEMENT RIGHT
WHERE
LEFT.TEST_SET_ELEM_ID=TECR .TEST_ELEM _COMPR_LEF T_SIDE_ID
AND RIGHT.TEST_SET_ELEM_ID=TEC R.TEST_ELE M_COMPR_RI GHT_SIDE_I D
AND TECR.COMPR_RUN_ID = 1120
How can I include those records and the records I already have in my First_Run_Report?
first-run-report.zip
I have written the following code to view the results seen in the attached report called: .xls. What I am having a problem with is I cannot include the records for “RightScenarioMissing” found in the field STAT_CD seen in the attached First_Run_ReportTEST_ELEME
Here’s the code I'm talking about:
SELECT
TECR.COMPR_RUN_ID as COMPR_RUN_ID,
left.TRAN_ID as LTRAN_ID,
right.TRAN_ID as RTRAN_ID,
left.INTFC_NM as INTFC_NM,
tecr.COMPR_RSULT_STAT_CD as STAT_CD,
left.TEST_SCNRO_ID as TEST_SCNRO_ID,
left.EXPTD_UNIQ_DESCR_VALU
right.EXPTD_UNIQ_DESCR_VAL
FROM
TEST_ELEMENT_COMPARE_RESUL
WHERE
LEFT.TEST_SET_ELEM_ID=TECR
AND RIGHT.TEST_SET_ELEM_ID=TEC
AND TECR.COMPR_RUN_ID = 1120
How can I include those records and the records I already have in my First_Run_Report?
first-run-report.zip
ASKER
Sorry but would you mind writing this out in the code so I can see what you mean?
Thanks so much.
Thanks so much.
The code above works as typed. Copy and paste in your environment and it should illustrate exactly what I am suggesting. Instead of an INNER JOIN which is what you had just in non-ANSI format, you need a LEFT OUTER JOIN as shown in my code snippet above. I did not have my Oracle instance running, so I had to convert the aliases LEFT and RIGHT to l and r, respectively as LEFT and RIGHT are functions in T-SQL and so were causing errors. If you want to change those back, then go right ahead. It does not change the solution, though, which is the JOIN type change.
ASKER
SELECT
tecr.COMPR_RUN_ID as COMPR_RUN_ID,
left.TRAN_ID as LTRAN_ID,
right.TRAN_ID as RTRAN_ID,
left.INTFC_NM as INTFC_NM,
tecr.COMPR_RSULT_STAT_CD as STAT_CD,
left.TEST_SCNRO_ID as TEST_SCNRO_ID,
left.EXPTD_UNIQ_DESCR_VALUE_DESC as dest_NR_LEFT,
right.EXPTD_UNIQ_DESCR_VALUE_DESC as dest_NR_RIGHT
FROM
transaction_descriptions L,transaction_descriptions R, TEST_ELEMENT_COMPARE_RESULT tecr
LEFT OUTER JOIN left ON tecr.TEST_SET_ELEM_ID=
tecr.TEST_ELEM_COMPR_LEFT_SIDE_ID
LEFT OUTER JOIN right.TEST_SET_ELEM_ID= MISC ON right.TEST_SET_ELEM_ID=
tecr.TEST_ELEM_COMPR_RIGHT_SIDE_ID
WHERE
left.EXPTD_UNIQ_DESCR_VALUE_DESC = L.TRACKING_NR
AND right.EXPTD_UNIQ_DESCR_VALUE_DESC = R.TRACKING_NR
and tecr.COMPR_RUN_ID = 1120
I tried the Left outer join before and it still didn't get these records.
That code looks much different. can you paste the true original code that was working and I will make the correction. The problem is you have criteria on the right table in the where clause, so this is acting like an inner join .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for all of your help. - I thought I closed this the other day but it didn't work.
Here is an example with ANSI-compliant JOINs to illustrate the suggestion.
Open in new window
Note: if the LEFT side should only be included on matches, then change that back to an INNER JOIN. As it stands, the current query returns 'LeftTranMissing' and 'RightScenarioMissing', which were both missing from the previous FIRST_RUN_REPORT.