[Q]: sqlplus view question using outer join

From: Neil Greene <Neil_at_bMD.com>
Date: Tue, 17 May 1994 01:31:01 GMT
Message-ID: <1994May17.013101.13070_at_bMD.com>


I have a view which merges two tables on three fields through an outer join. The only problem is, I only what the view to merge the two tables on only one occurance of the outer joins and NOT on all the possible rows.

Here is the view:

create view az_submissions

        as select 
                SOURCE.LNAME lname,
                SOURCE.FNAME fname,
                SOURCE.MNAME mname,
                SOURCE.SSN ss, 
                SOURCE.BIRTHDATE bday,
                SOURCE.MYLICENSECODE licensecode,
                SOURCE.MYDIVISIONCODE division,
                SOURCE.ISSUEDATE issuedate,
                SOURCE.EXPIREDATE expiredate,
                SOURCE.LOADSEQ loadseq,
                DEST.NASRISID myNASRISID, 
                DEST.LNAME myLNAME,
                DEST.SS mySS, 
                DEST.BIRTHDATE myBDAY
        from    az_licenses source, master dest
        where   SOURCE.SSN = DEST.SS (+) AND
                SOURCE.BIRTHDATE = DEST.BIRTHDATE (+) AND
                SOURCE.LNAME = DEST.LNAME (+);

I would like to do someting like the above except modify the select statement to something like the following:

create view az_submissions

        as select 
                SOURCE.LNAME lname,
                SOURCE.FNAME fname,
                SOURCE.MNAME mname,
                SOURCE.SSN ss, 
                SOURCE.BIRTHDATE bday,
                SOURCE.MYLICENSECODE licensecode,
                SOURCE.MYDIVISIONCODE division,
                SOURCE.ISSUEDATE issuedate,
                SOURCE.EXPIREDATE expiredate,
                SOURCE.LOADSEQ loadseq,

----> min(DEST.NASRISID) myNASRISID, <-- Here is the catch
DEST.LNAME myLNAME, DEST.SS mySS, DEST.BIRTHDATE myBDAY from az_licenses source, master dest where SOURCE.SSN = DEST.SS (+) AND SOURCE.BIRTHDATE = DEST.BIRTHDATE (+) AND SOURCE.LNAME = DEST.LNAME (+);

In the first view I can get into situations where the source table contains 100 records and yet the view contains 114 records if an applicant is found in the destination tables more then once. However, I only want the view to select the first, or minimum NASRISID, record were the outer joins are valid.

Does anyone have any solutions to this problem. Oracle support is currently looking into a solution as well.

-- 
Sincerely,

Neil Greene
Received on Tue May 17 1994 - 03:31:01 CEST

Original text of this message