Need assistance with JOIN SQL

From: <paul.wilson198_at_gmail.com>
Date: Tue, 11 Dec 2018 08:07:15 -0800 (PST)
Message-ID: <3e75d1ff-048c-4dc6-927d-a82bf058d5f3_at_googlegroups.com>



[Quoted] I am attempting to create a report that shows both Primary and there Alternates however both tables I have use the same PERSON_ID identifier. Can someone assist me or give me something to try. The query below gives me output, but it only gives me Primary First Name/Last Name ect, email address ect ect and then it only shows the Alternates ID number opposed to giving me there First NAME/Last name ect ect. I know I need to use a join statement, but I have no experience with JOINS. PLEASE HELP!!

[Quoted] SELECT "ORG_ACCOUNT".ACCOUNT_NUMBER AS "Account Number",

"ORG_PERSON".ADDRESS_2 AS "Address",
"ORG_ACCOUNT".DODAAC AS "Dodaac",
"ORG_DODAAC".DRA AS "Dra",
"ORG_PERSON".EMAIL AS "Email",
"ORG_PERSON".FIRST_NAME AS "First Name",
"ORG_PERSON".LAST_NAME AS "Last Name",
"ORG_PERSON".LAST_TRAIN_DATE AS "Last Train Date",
"ORG_PERSON".MIDDLE_NAME AS "Middle Name",
"ORG_ALT_ACCOUNT_CUST".PERSON_ID AS "Alt Person Id",
"ORG_ORG".ORG_NAME AS "Org Name",
"ORG_ACCOUNT".PERSON_ID AS "Person Id",
"ORG_PERSON".PHONE_COM AS "Phone Com",
"ORG_PERSON".PHONE_DSN AS "Phone Dsn",
"ORG_PERSON".RANK AS "Rank"

               FROM "ORG"."ORG_ACCOUNT" "ORG_ACCOUNT",
                    "ORG"."ORG_DODAAC" "ORG_DODAAC",
                    "ORG"."ORG_ORG" "ORG_ORG",
                    "ORG"."ORG_PERSON" "ORG_PERSON",
                    "ORG"."ORG_ALT_ACCOUNT_CUST" "ORG_ALT_ACCOUNT_CUST"
[Quoted]                WHERE ( ( "ORG_PERSON".PERSON_ID(+) = "ORG_ALT_ACCOUNT_CUST".PERSON_ID )
                                                   AND   ( "ORG_ORG".ORG_ID = "ORG_ACCOUNT".ORG_ID ) 
                                                   AND   ( "ORG_PERSON".PERSON_ID = "ORG_ACCOUNT".PERSON_ID )
                                                   AND   ( "ORG_ALT_ACCOUNT_CUST".PERSON_ID = "ORG_ACCOUNT".PERSON_ID )
                                                   AND   ( "ORG_DODAAC".DODAAC = "ORG_ACCOUNT".DODAAC ) ) 
                                                   AND   ( UPPER("ORG_ACCOUNT".DODAAC) LIKE UPPER(:DODAAC) 
                                                   AND    "ORG_DODAAC".DRA IN ( :P_DRA_ENTRIES)
                                                   AND     UPPER("ORG_ACCOUNT".DODAAC_COMMODITY) = UPPER('A') )
               ORDER BY "ORG_DODAAC".DRA ASC, "ORG_ACCOUNT".ACCOUNT_NUMBER ASC, "ORG_PERSON".LAST_NAME ASC, "ORG_ALT_ACCOUNT_CUST".PERSON_ID ASC
Received on Tue Dec 11 2018 - 17:07:15 CET

Original text of this message