Left Outer Join help...

Hello world

I'm still trying to learn the SQL, and I can not specifically with the left outer join.  I normally join tables using equijoin, but I don't get the right data set returns, and designed with the help of a left or right outer join would solve the problem...

Here is my SQL that works properly with 1 left outer join.  I build the slow query in the SQL following, you will see where I see the error.  I don't expect you to understand the data and the columns, I'm trying to join, I think the problems I encounter are related to syntax, and I hope that you can find where are my syntax errors.

Select

s.Name as "Pseudonym,"

SV.view_name as "name of the view.

s_view. Name

Of

s s_screen,

s_screen_view sv

outer join left s_view

WE (sv.view_name = s_view.name)

where

SV.screen_id = ' 1-866 A - 1X3LU' and

s.ROW_ID = sv.screen_id and

s.repository_id = ' 866 A-1-1"and

s_view.repository_id = ' A-1-1 866 ";

Here is the SQL code where I encounter the following error...

Error:

ORA-00904: "SV". "" View_name ": invalid identifier

00904, 00000 - '% s: invalid identifier '.

* Cause:

* Action:

Error on line: column 14: 7

Problematic SQL:

Select

s.Name as "Pseudonym,"

SV.view_name as "name of the view.

s_view. Name,

s_applet. Name as Applet

-b.SID like "name of the cmdlet.

Of

s s_screen,

s_screen_view sv,

wti s_view_wtmpl_it

outer join left s_view

WE (sv.view_name = s_view.name)

outer join left s_applet

WE (wti.name = s_applet.name)

where

SV.screen_id = ' 1-866 A - 1X3LU' and

s.ROW_ID = sv.screen_id and

s.repository_id = ' 866 A-1-1"and

s_view.repository_id = ' A-1-1 866 ";

Thanks in advance for your help.

Chris

> ORA-00904: "S_VIEW_WEB_TMPL." "" ROW_ID ": invalid identifier

I don't see this table in your FROM clause.

Tags: Database

Similar Questions

  • Help for a LEFT OUTER JOIN query

    Hello, all,.

    I'm having some trouble setting up an Oracle 11 g Server SQL query, and I could use some help.

    Let's say tableA is blogs; tableC is comments for blog entries; tableB is the associative array:

    tableA
    blogID        blogTitle       blogBody      dateEntered
    1             This is a test  More text...  2016-05-20 11:11:11
    2             More testing    Still more!   2016-05-19 10:10:10
    3             Third charm!!   Blah, blah.   2016-05-18 09:09:09
    

    tableC
    commID        userID          userText      dateEntered
    10            Bravo           I like it!    2016-05-20 11:21:31
    11            Charlie         I don't!      2016-05-20 11:31:51
    12            Alpha           Do it again!  2016-05-19 10:20:30
    13            Bravo           Still more?   2016-05-19 10:30:50
    14            Charlie         So, what?     2016-05-19 10:35:45
    15            Bravo           Blah, what?   2016-05-18 09:10:11
    16            Alpha           Magic number! 2016-05-18 09:11:13
    

    tableB
    blogID        commID
    1             10
    1             11
    1             12
    2             13
    2             14
    3             15
    3             16
    
    
    
    

    I'm trying to get blogID, blogTitle, blogBody and the number of comments for each blog entry.  But, since I'm on to_char() for date and COUNT (commID) for the total number of comments, I am not "a group by expression.

    Here is an example of pseudo-SQL of what I'm trying.

    SELECT a.blogID, a.blogTitle, a.blogBody, to_char(a.dateEntered,'YYYY-MM-DD HH24:MI:SS') as dateEntered, COUNT(c.commID) as total
    FROM tableA a LEFT OUTER JOIN tableB b ON b.blog_ID = a.blog_ID
                  LEFT OUTER JOIN tableC c ON c.commID = b.commID
    WHERE a.blogID = '1'
    GROUP BY blogID, blogTitle, blogBody
    ORDER BY to_date(dateEntered,'MM-DD-YYYY HH24:MI:SS') desc
    

    I'm sure it's something simple, but I just DO NOT see it.  Can you help me?

    V/r,

    ^_^

    Try:

    GROUP BY a.blogID, a.blogTitle, a.blogBody, to_char(a.dateEntered,'YYYY-MM-DD HH24:MI:SS')
    

    See you soon

    Eddie

  • Modeling of the left outer join

    Hello world

    I'm tender hand to you guys for a modeling help

    I have a FACT, the customers, the Dim_Date and CUST_ADDRESS of tables to model

    Fact and the client are joined through CUST_ID

    FACT and DATE are joined through DATE_ID

    CUST_ADDRESS must be attached to the top of the model through CUST_ID, DATE_ID and this join must be Left outer because sometimes the address does not exist or is not current, which means DATE_ID could be different between Dim_Date and CUST_ADDRESS

    If it were to join internal, model would have been easy, because of the outside left that I am unable to model, it's pretty good.

    Application under
    Select D.DATE, C.CUST_NAME, CA. ADDRESS, F.AMOUNT
    Of
    F FACT
    JOIN THE
    CUSTOMER C
    ON C.CUST_ID = F.CUST_ID
    JOIN THE
    DIM_DATE D
    ON F.DATE_ID = D.DATE_ID
    LEFT OUTER JOIN
    CUST_ADDRESS CA
    ON C.CUST_ID = CA. CUST_ID AND C.DATE_ID = D.DATE_ID

    Thanks in advance

    When I add the CUSTOMER and in FACT LTS CUST_ADDRESS

    Stop it!

    Don't add CUSTOMER and CUST_ADDRESS in the FACT of LTS. Why would add you to the LTS DO?

    You design a management model: CUSTOMER is a dimension and it has its own logical table this logic table join with a logical join in the activity diagram. Ditto for CUST_ADDRESS.

    So the change, I missed earlier is CUST_ADDRESS contains no Cust_ID (ACTUALLY existing), but contains a Cust_NO, and the table to translate Cust_NO in Cust_ID is CUSTOMER?

    No problem...

    Let's start with a new alias of CUSTOMER (to keep more simple to understand at the moment), call as you want, but this new alias will be the link between the FACT and CUST_ADDRESS.

    In LTS of the dimension 'Address', you have CUST_ADDRESS initially, add an inner join on the new alias that you created in the LTS of the CUSTOMER. So now your 'Address' logical dimension contains the Cust_NO and Cust_ID and this will make the join to FACT.

    Between CUST_ADDRESS and the CLIENT, you can keep an inner join, because the target is not not for get the address of the customer, but is having the Cust_ID in the address line.

    Give it a try at that.

    But do not add these tables in the LTS, they are logical dimensions.

  • left outer join, after summarizing

    Hello

    I need to create a summary of a lot of tables and join the result set with another table. The other table must do a left outer join. When I do a left outer join, the column which do not appear in the second table appear as a draft. However, I would like to than all results in the table on the right to replicate once for each row in the left table.  Here is a sample data set:

    CREATE THE TRIGHT TABLE

    (

    PKEY CHAR(1),

    AMT NUMERIC (13.2).

    GRP TANK (4),

    FILTER TANK (3)

    )

    INSERT INTO TRIGHT VALUES ('A', 200 ' GRP1 "," XXX ");

    INSERT INTO TRIGHT VALUES ('A', 500, "GRP2', 'XXX'");

    INSERT INTO TRIGHT VALUES ('A', 150 'GRP1', 'YYY');

    INSERT INTO TRIGHT VALUES ('A', 100, "GRP2', 'YYY'");

    CREATE THE TLEFT TABLE

    (

    PKEY CHAR (1)

    )

    INSERT INTO VALUES TLEFT ('A')

    INSERT INTO TLEFT VALUES ('B')

    SELECT A.PKEY, GRP, SUM (AMT) OF TLEFT A LEFT JOIN

    (SELECT PKEY, GRP, SUM (AMT) AS AMT IN TRIGHT)

    WHERE FILTER = "XXX".

    PKEY, GRP) B

    ON A.PKEY = B.PKEY

    A.PKEY GROUP, GRP

    The result I get is:

    A 200 GRP1

    A 500 GRP2

    B (white) (white)

    Instead, I would like the following:

    A 200 GRP1

    A 500 GRP2

    GRP1 B 0

    B GRP2 0

    Can anyone help? Thanks in advance.

    Sorry, I couldn't find the button skip yet, although there is an urgent need for such a feature in this forum.

    That is why another chance for you:

    SELECT

    a.PKEY

    GRP

    SUM (case

    When a.pkey = b.pkey

    can AMT 0 otherwise

    AMT end)

    Of

    TLEFT HAS

    Cross JOIN

    TRIGHT B

    where FILTER = "XXX".

    GROUP BY a.PKEY, GRP

    ORDER BY a.PKEY, GRP

    PKEY GRP AMT
    A GRP1 200
    A GRP2 500
    B GRP1 0
    B GRP2 0
  • Left outer join error 2

    Hi all

    11.2.0.1

    I have two 2 left outer join in my application, but I got errror

    Ths is supported?

    It is something like:

    Select tab1, b.col1, a.col1, c.col1 one

    LEFT OUTER JOIN tab2 b

    ON a.id = b.id;

    LEFT OUTER JOIN tab 3 c

    ON a.id = c.id;

    My syntax is correct? I got the error ora-942.

    Help, please...

    Thank you

    Then use script below

    SELECT A.ACRNUMBER AS ACR_NO, A.LASTNAME, A.GIVENNAME AS FIRSTNAME, A.MIDDLENAME, A.BIRTHDATE, A.GENDER,NLV2(F.COUNTRYID3,'XXX'), A.PROBSTAYLENGTH AS PROB_STAY_LENGHT,A.SECTIONISSUED AS SECTION_ISSUED, A.RESIDENCECERTIFICATENUMBER AS RESIDENCE_CERTIFICATE_NO, A.ACTIVESTATUS AS STATUS, B.CLIP
    IMAGE AS PHOTO, C.SIGBMP AS SIGNATURE,D.CARDISSUErNUMBER AS CARD_NO, D.CARDEXPIRYDATE AS CARD_VALIDITY, D.CARDSERIALNUMBER AS CARD_SERIAL_NO, D.CARDISSUEDATE AS CARD_DATE_ISSUED, nvl2( d.CARDSERIALNUMBER,'0','1') AS CARD_STATUS
           From   Acrmaster  A Inner Join  Pictures  B  On A.Acrnumber=B.Acrnumber
                           Inner Join  Signature  C On B.Acrnumber=C.Acrnumber
                           Inner Join  Acrcarddetails D On   C.Acrnumber=D.Acrnumber
                           Left Outer Join Acrblockcarddetails E On (D.Acrnumber=E.Acrnumber And D.Cardserialnumber=E.Cardserialnumber)
                           Left Outer Join Countrymaster_Lk F ON  A.NATIONALITY=F.ID
    

    You have error here:

    left outer join ACRBLOCKCARDDETAILS E

    Left Outer join Countrymaster_Lk F on d.acrnumber = e.acrnumber and d.CARDSERIALNUMBER = e.CARDSERIALNUMBER and A.NATIONALITY = F.ID

    Concerning

    Mr. Mahir Quluzade

  • Problem with LEFT OUTER JOIN

    Hello

    I am in charge of the migration of a SQL Server 2000 database to Oracle 11 g, under what I also migrate some predefined queries, that my client has. However I can't seem to get the syntax right and it keeps failing. Could you please help me? Thank you.

    Query:
    SELECT *,(select r.recsolins from gx.repara r where r.percod=c.percod and r.concod=c.concod and r.rectpo='I' and r.recsts='F' and r.grppercod=10 and r.recnro=(select max(t.recnro) from gx.repara t where t.percod=c.percod and t.concod=c.concod and t.rectpo='I' andt.recsts='F' ) ) as NROID
    FROM gx.CONABO c, gx.abonad a  
    LEFT OUTER JOIN gx.CALLES y ON  y.dptocod=10 and y.ciucod=524 and y.CALCOD=A.AboCalEsq1, 
    LEFT OUTER JOIN gx.CALLES Z ON  z.dptocod=10 and z.ciucod=524 and z.CALCOD=A.AboCalEsq2 
    ,gx.calles x WHERE c.PERCOD in (10,60) and CONSTSHAB in ('C','D','P')
    and a.percod=c.percod and a.abocod=c.abocod and
    x.dptocod=10 and x.ciucod=524
    and x.calcod=abocal
    order by c.percod,c.concod;
    The fields are correct, but I get not found when expected in FROM clause.

    Published by: n on June 5, 2012 13:47
  • Left outer join without data in a table

    I have two tables defined (see below). Emp table has given, and there is still no data in the table of Emp_Type! Now it is empty.

    I want to write a query that returns the data from the tables, even if there is no data in the Emp_type table. I use a left outer join but it return nothing. Can anyone help?
    create table EMP
    (
      EMPID   NUMBER(10,2),
      EMPNAME VARCHAR2(100)
    );
    
    INSERT INTO emp (empid,empname) values (1, 'Mark');
    INSERT INTO emp (empid,empname) values (2, 'Jason');
    INSERT INTO emp (empid,empname) values (3, 'Kevin');
    INSERT INTO emp (empid,empname) values (4, 'Drew');
    INSERT INTO emp (empid,empname) values (5, 'Jessica');
    INSERT INTO emp (empid,empname) values (6, 'Pena');
    INSERT INTO emp (empid,empname) values (7, 'Roxanne');
    
    create table EMP_Type
    (
      ID          NUMBER(10,2),
      EMPID       NUMBER(10,2),
      TYPE_ID     NUMBER(10,2),
      END_DATE    DATE
    );
    
    No data
    
    select *
      from emp e
      left outer join emp_Type t
        on e.empid = t.empid
     WHERE t.type_id = 1
       and t.end_date is null;

    WHERE t.type_id = 1

    will be ever true when table has no rows (or t.type_id is NULL?)

  • What is the difference between NOT IN and LEFT OUTER JOIN

    Hello

    I searched the difference between everywhere. But his powerlessness.
    Please tell me the differences.

    Thanks in advance
    KVB

    It's like comparing apples and oranges.

    NOT IN - exclude all lines matching the condition NOT IN (beware of NULL values).

    JOIN EXTERNAL - return of rows from the inner table even if there is no corresponding row in the outer table.

    SQL> -- NOT IN
    SQL> with x as
      2  (select 1 col1 from dual union all
      3   select 2 col1 from dual union all
      4   select 3 col1 from dual)
      5  ,    y as
      6  (select 1 col1 from dual)
      7  select *
      8  from   x
      9  where  col1 not in (1,2);
    
          COL1
    ----------
             3
    
    SQL> -- NOT IN (subquery)
    SQL>
    SQL> with x as
      2  (select 1 col1 from dual union all
      3   select 2 col1 from dual union all
      4   select 3 col1 from dual)
      5  ,    y as
      6  (select 1 col1 from dual)
      7  select *
      8  from   x
      9  where  col1 not in (select col1 from y);
    
          COL1
    ----------
             2
             3
    
    SQL> -- OUTER JOIN
    SQL> with x as
      2  (select 1 col1 from dual union all
      3   select 2 col1 from dual union all
      4   select 3 col1 from dual)
      5  ,    y as
      6  (select 1 col1 from dual)
      7  select *
      8  from   x
      9  left outer join
     10         y
     11  on x.col1 = y.col1;
    
          COL1       COL1
    ---------- ----------
             1          1
             3
             2
    
    SQL> -- Maybe it helps to contrast LOJ with just JOIN?
    SQL> with x as
      2  (select 1 col1 from dual union all
      3   select 2 col1 from dual union all
      4   select 3 col1 from dual)
      5  ,    y as
      6  (select 1 col1 from dual)
      7  select *
      8  from   x
      9  join   y
     10  on x.col1 = y.col1;
    
          COL1       COL1
    ---------- ----------
             1          1
    
    SQL> 
    
  • Left Outer Join does not work why?

    Hello

    I have a question I want to return all the id group grp_id table and count and give me a count of all "active" members in the Member table. There are a few members who are not active in the table of members who belong to groups in the grp_id table. I still want a record returned for these grpid, but since there is no active members for these groups, I would like a zero as the mbr_count. An active mbr is the one whose eff_dt is less than the date of the day and whose exp_dt is greater than today's date.

    I have listed the query below, which returns active records mbr, but unfortunately does not return a grpid (as in my example of data) is not an active member (grpid: has ""). I have also provided the DDL for both tables as well as some examples of data that gives me the (Incorrect) results, that I posted. I have also posted what I need (the 'Correct' results).

    Thanks for any help... (I use PL/SQL)

    THE QUERY I USE:
    =============
    SELECT
    G00.grpid,
    Count (M00.grpid) mbr_count
    Of
    g00 grp_id
    LEFT OUTER JOIN
    m00 MBR on
    G00.grpid = m00.grpid
    WHERE
    M00.eff_dt < sysdate
    AND
    M00.exp_dt > sysdate
    GROUP BY
    G00.grpid

    It gives me results like:

    INCORRECT RESULTS:
    ===============
    GRPID MBR_COUNT
    A 2
    B 2
    C 1

    I want to see is:

    CORRECT RESULTS
    ===============
    GRPID MBR_COUNT
    A 2
    B 2
    C 1
    D 0


    Here's the DOF and the sample data:

    create table grp_id (grpid varchar (1))

    insert into grp_id values ('A')
    insert into grp_id values ('B')
    insert into grp_id values ('C')
    insert into grp_id values (')

    Commit

    create table mbr (mbr_name varchar (10), varchar (1) grpid, eff_dt date, exp_dt date)

    insert into values of mbr ('BRAND', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
    insert into values of mbr ('BRAND', 'A', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

    insert into values of mbr ('MARTY', 'A', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
    insert into values of mbr ('MARTY', 'A', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

    insert into values of mbr ('FRANK', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
    insert into values of mbr ('FRANK', 'B', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

    insert into values of mbr ('MARY', 'B', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
    insert into values of mbr ('MARY', 'B', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

    insert into values of mbr ('JOHN', 'C', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY '))
    insert into values of mbr ('JOHN', 'C', to_date (July 1, 2011 ',' DD-MM-YYYY '), to_date (1 January 2012 ',' DD-MM-YYYY '))

    insert into values of mbr ("NOAM" 'd', to_date (January 1, 2011 ',' DD-MM-YYYY '), to_date (July 1, 2011 ',' DD-MM-YYYY ') ")

    Thanks for the script, shame on the missing semicolon :)

    Your date restrictions are implemented as "filter predicates" rather than "join predicates.
    that is the difference between a place ANDS extra o in the JOIN clause.

    SQL> SELECT
      2  g00.grpid,
      3  count(m00.grpid) mbr_count
      4  FROM
      5  grp_id g00
      6  LEFT OUTER JOIN
      7  mbr m00 on
      8  g00.grpid = m00.grpid
      9  WHERE
     10  m00.eff_dt < sysdate
     11  AND
     12  m00.exp_dt > sysdate
     13  GROUP BY
     14  g00.grpid
     15  /
    
    G  MBR_COUNT
    - ----------
    A          4
    B          4
    C          2
    
    SQL> SELECT
      2  g00.grpid,
      3  count(m00.grpid) mbr_count
      4  FROM
      5  grp_id g00
      6  LEFT OUTER JOIN
      7  mbr m00 on
      8  g00.grpid = m00.grpid
      9  AND
     10  m00.eff_dt < sysdate
     11  AND
     12  m00.exp_dt > sysdate
     13  GROUP BY
     14  g00.grpid;
    
    G  MBR_COUNT
    - ----------
    D          0
    A          4
    B          4
    C          2
    
    SQL> 
    
  • Problem with XMLTABLE and LEFT OUTER JOIN

    Hi all.

    I have a problem with XMLTABLE and LEFT OUTER JOIN, in 11g it returns the correct result, but in 10g it doesn't, it is illustrated as a INNER JOIN.
    SELECT * FROM v$version;
    
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE     11.2.0.1.0     Production"
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    
    --test for 11g
    
    CREATE TABLE XML_TEST(
         ID NUMBER(2,0),
         XML XMLTYPE
    );
    
    INSERT INTO XML_TEST
    VALUES
    (
         1,
         XMLTYPE
         ('
              <msg>
                   <data>
                        <fields>
                             <id>g1</id>
                             <dat>data1</dat>
                        </fields>
                   </data>
              </msg>
         ')
    );
    
    INSERT INTO XML_TEST
    VALUES
    (
         2,
         XMLTYPE
         ('
              <msg>
                   <data>
                        <fields>
                             <id>g2</id>
                             <dat>data2</dat>
                        </fields>
                   </data>
              </msg>
         ')
    );
    
    INSERT INTO XML_TEST
    VALUES
    (
         3,
         XMLTYPE
         ('
              <msg>
                   <data>
                        <fields>
                             <id>g3</id>
                             <dat>data3</dat>
                        </fields>
                        <fields>
                             <id>g4</id>
                             <dat>data4</dat>
                        </fields>
                        <fields>
                             <dat>data5</dat>
                        </fields>
                   </data>
              </msg>
         ')
    );
    
    SELECT
         t.id,
         x.dat,
         y.seqno,
         y.id_real
    FROM
         xml_test t,
         XMLTABLE
         (
              '/msg/data/fields'
              passing t.xml
              columns
                   dat VARCHAR2(10) path 'dat',
                   id XMLTYPE path 'id'
         )x LEFT OUTER JOIN
         XMLTABLE
         (
              'id'
              passing x.id
              columns
                   seqno FOR ORDINALITY,
                   id_real VARCHAR2(30) PATH '.'
         )y ON 1=1
    ;
    
    ID     DAT     SEQNO     ID_REAL
    --     -----     -----     -------
    1     data1     1     g1
    2     data2     1     g2
    3     data3     1     g3
    3     data4     1     g4
    3     data5          
    This is all nice, now the problem:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for HPUX: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    --exactly the same environment as 11g (tables and rows)
    SELECT
         t.id,
         x.dat,
         y.seqno,
         y.id_real
    FROM
         xml_test t,
         XMLTABLE
         (
              '/msg/data/fields'
              passing t.xml
              columns
                   dat VARCHAR2(10) path 'dat',
                   id XMLTYPE path 'id'
         )x LEFT OUTER JOIN
         XMLTABLE
         (
              'id'
              passing x.id
              columns
                   seqno FOR ORDINALITY,
                   id_real VARCHAR2(30) PATH '.'
         )y ON 1=1
    ;
    
    ID     DAT     SEQNO     ID_REAL
    --     -----     -----     -------
    1     data1     1     g1
    2     data2     1     g2
    3     data3     1     g3
    3     data4     1     g4
    As you can see in 10g that I don't have the last row, it seems that Oracle 10 g does not recognize the LEFT OUTER JOIN.

    Is this a bug?, Metalink says that sometimes we can have an ORA-0600, but in this case there is no error results returned, just incorrect.

    Help, please.

    Kind regards.

    What about try the original Oracle method for outer joins? Using (+) without the extra space

    XMLTABLE(...COLUMNS ... id XMLTYPE PATH ... ) x,
    XMLTABLE(... PASSING x.id ...) (+) y
    
  • Using Left Outer Join with reference

    I have three tables.
    Table 1: BOOK_DETAILS
    Fields: BOOK_ID, BOOK_NAME

    Table 2: BOOK_ISSUE_RECORD
    Fields: BOOK_ID, USER_NAME

    Table 3: BOOK_AUTHOR
    Fields: BOOK_ID, AUTHOR_NAME

    I must link table 1 and table 2 with a left outer join, because even if the book is not the questions to anyone, his name should come.
    I have once again display the name of the author of books for each book.
    I am able to create a query with the left outer join between table 1 and table 2. However, I am not able to give a reference to Table 3.
    Can someone help me with this please.

    Concerning
    Hawker
    select  d.book_name,
            a.book_author,
            i.user_name
      from       book_details d
            join
                 book_author a
              on (d.book_id = a.book_id)
            left join
                 book_issue_recors i
              on (d.book_id = i.book_id)
    /
    

    SY.

  • Problem format (LEFT OUTER JOIN)?

    THE addresses of Mutiple of return as a single record + current addresses

    >
    Hi all

    I have to back student addresses home and dormitory under a single registration.

    He had to go something like this:
    LAST_NAME     FIRST_NAME     ADDY_TYPE   ADDRESS             ZIP
    Smith                John             HOME         123 Awesome St     10003
    Smith               John               DORM         Oak Quad             10013
    In this format the desired:
    LAST_NAME  FIRST_NAME     ADDY_TYPE  ADDRESS         ZIP        ADDY_TYPE     ADDRESS     ZIP
    Smith            John      HOME        123 Awesome St  10003   DORM            Oak Quad     10013
    You also need to get their last addresses by date.
    The database hold records of all students have places moving from dorm to dorm
    and some permanent residence ("HOME") has changed as well.
    To return only a DORM address and only a HOME address
    for each student.

    I'm looking at possibly a function BOX to put on a line/record and RANK BY() or DENSE_RANK to determine the last addresses.

    Hope I'm making some sense and as always very grateful for any help. Thank you.
    >

    The correct code provided by Frank Kulash here:
    WITH    got_rnum     AS
    (
         SELECT     last_name
         ,     first_name
         ,     addy_type
         ,     address
         ,     zip
         ,     ROW_NUMBER () OVER ( PARTITION BY  last_name
                                   ,                    first_name
                             ,             addy_type
                             ORDER BY        addy_date     DESC     NULLS LAST
                           ) AS rnum
         FROM    table_x
    --     WHERE     ...          -- Any filtering goes here
    )
    SELECT    last_name
    ,       first_name
    ,       MIN (CASE WHEN addy_type = 'HOME' THEN address END)     AS home_address
    ,       MIN (CASE WHEN addy_type = 'HOME' THEN zip     END)     AS home_zip
    ,       MIN (CASE WHEN addy_type = 'DORM' THEN address END)     AS dorm_address
    ,       MIN (CASE WHEN addy_type = 'DORM' THEN zip     END)     AS dorm_zip
    FROM       got_rnum
    WHERE       rnum     = 1
    GROUP BY  last_name
    ,            first_name
    ;
    I need to add a 'NATION' field, located on another table for the addresses of welcome for foreign students.
    I made a LEFT OUTER JOIN with the table of the NATION and the release came out like this:
    LAST_NAME  FIRST_NAME     ADDY_TYPE  ADDRESS   ZIP      NATION    ADDY_TYPE       ADDRESS     ZIP
    Smith            John      HOME        Rue Henry M1V 4F4  CANADA      null              null             null
    Smith            John      null        null      null     null        DORM               Oak Quad     10013
    My desired output would be like this:
    LAST_NAME  FIRST_NAME     ADDY_TYPE  ADDRESS   ZIP      NATION    ADDY_TYPE       ADDRESS     ZIP
    Smith            John      HOME        Rue Henry M1V 4F4  CANADA    DORM              Oak Quad     10013
    Maybe it's something I'm not right. What is the way I'm joining tables?

    As always very grateful for your contributions. Thank you.

    Give a glance to your group by, you group on the nation, but it has two values (NULL and CANADA). Try this way:

    WITH    got_rnum     AS
    (
         SELECT     STUINFO_id
      , STUINFO_last_name
         ,     STUINFO_first_name
         ,     ADDRESSLIST_atyp_code
         ,     ADDRESSLIST_street_line1
      , ADDRESSLIST_street_line2
      , ADDRESSLIST_city
      , ADDRESSLIST_stat_code
         ,     ADDRESSLIST_zip
    
    , ADDRESSLIST_natn_code
    , NATION_nation
         ,     ROW_NUMBER () OVER ( PARTITION BY  STUINFO_last_name
                                   ,                    STUINFO_first_name
                             ,                         ADDRESSLIST_atyp_code
    
                             ORDER BY        ADDRESSLIST_from_date     DESC     NULLS LAST
                           ) AS rnum
         FROM STUINFO JOIN CLASSROSTER ON STUINFO_pidm = CLASSROSTER_pidm JOIN ADDRESSLIST ON ADDRESSLIST_pidm = STUINFO_pidm LEFT OUTER JOIN NATION ON ADDRESSLIST_NATN_CODE =NATION_CODE
    -- The WHERE part determines if the student is currently enrolled in a class
    -- ADDRESSLIST_to_date is the last date the student will be living in that residence
    WHERE ADDRESSLIST_atyp_code IN ('PR', 'CA') and  STUINFO_change_ind IS NULL and STUINFO_last_name !='Registrar'
    and CLASSROSTER_term_code='200909' and CLASSROSTER_PTRM_CODE IN ('D', 'D1', 'D2') and CLASSROSTER_CAMP_CODE='1'
    
    and (ADDRESSLIST_to_date is NULL OR ADDRESSLIST_TO_DATE > SYSDATE)
    )
    SELECT    STUINFO_id
    ,   STUINFO_last_name
    ,       STUINFO_first_name
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_STREET_LINE1  END)     AS PR_ADDRESSLIST_STREET_LINE1
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_STREET_LINE2  END)     AS PR_ADDRESSLIST_STREET_LINE2
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_city     END)     AS PR_ADDRESSLIST_city
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_stat_code     END)     AS PR_ADDRESSLIST_stat_code
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'PR' THEN ADDRESSLIST_zip     END)     AS PR_ADDRESSLIST_zip
    ,       MIN (CASE WHEN ADDRESSLIST_natn_code IS  NULL THEN ADDRESSLIST_natn_code     END)     AS PR_ADDRESSLIST_natn_code
    , MIN(NATION_nation) NATION_nation
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_STREET_LINE1  END)     AS CA_ADDRESSLIST_STREET_LINE1
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_STREET_LINE2  END)     AS CA_ADDRESSLIST_STREET_LINE2
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_city     END)     AS CA_ADDRESSLIST_city
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_stat_code     END)     AS CA_ADDRESSLIST_stat_code
    ,       MIN (CASE WHEN ADDRESSLIST_atyp_code = 'CA' THEN ADDRESSLIST_zip     END)     AS CA_ADDRESSLIST_zip
    
    FROM       got_rnum
    WHERE       rnum     = 1
    GROUP BY  STUINFO_last_name
    ,            STUINFO_first_name
    ,         STUINFO_id
    ORDER BY STUINFO_last_name;
    

    Max

  • Oracle: Use LEFT OUTER JOIN, but convert the data to an external list

    Hello, all,.

    I know it can be done; I just don't remember how I got it done, oh there are so many years.

    Assumes that the tables exist for groups and individuals.  People can belong to several groups.

    SELECT g.groupName, p.lastName || ', ' || p.firstName as fullName
    FROM groups g LEFT OUTER JOIN groupPersonAssociation gpa ON gpa.groupID = g.groupID
                  LEFT OUTER JOIN person p ON p.personID = gpa.personID
    ORDER BY g.groupName, fullName
    

    This gives us:

    Group One          Alpha, Daniel
    Group One          Bravo, Charles
    Group One          Charlie, Chuck
    Group Two          Beta, Alpha
    Group Two          Delta, Bonnie
    Group Three        Echo, Bunny
    Group Three        Golf, Samuel
    Group Three        November, Stan
    

    How word the SQL to get the data as:

    Group One          Alpha, Daniel | Bravo, Charles | Charlie, Chuck
    Group Two          Beta, Alpha | Delta, Bonnie
    Group Three        Echo, Bunny | Golf, Samuel | November, Stan
    

    V/r,

    ^_^

    I finally thought to it.  I was using incorrect keywords on Google.

    SELECT g.groupName, LISTAGG(p.lastName || ', ' || p.firstName,' | ') WITHIN GROUP (ORDER BY g.groupName) "fullName"
    FROM groups g LEFT OUTER JOIN groupPersonAssociation gpa ON ggpa.groupID = g.groupID
                  LEFT OUTER JOIN person p ON p.personID = gpa.personID
    GROUP BY g.groupName
    ORDER BY g.groupName, fullName  
    

    Just in case someone else is going through this same desire.

    HTH,

    ^_^

  • doubt left outer join

    Hi all

    I use under version

    Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0

    SQL > SELECT E.ENAME,.

    2 D.DEPTNO,

    3 D.LOC

    4. TO EMP E,.

    DEPT 5 D

    6. WHERE = E.DEPTNO D.DEPTNO (+);

    ENAME, DEPTNO LOC

    ---------- ------ -------------

    DALLAS SMITH 20

    ALLEN 30 CHICAGO

    WARD 30 CHICAGO

    20 DALLAS JONES

    MARTIN 30 CHICAGO

    BLAKE 30 CHICAGO

    CLARK 10 NEW YORK

    SCOTT 20 DALLAS

    THE 10 NEW YORK KING

    TURNER 30 CHICAGO

    20 DALLAS ADAMS

    JAMES 30 CHICAGO

    FORD 20 DALLAS

    MILLER 10 NEW YORK

    40 BOSTON

    15 selected lines

    -----------------------------------------------------------------------------------------------------------------------------

    SQL > SELECT E.ENAME,.

    2 D.DEPTNO,

    3 D.LOC

    4. TO EMP E

    5 LEFT OUTER JOIN

    D 6 DEPT

    7. THE E.DEPTNO = D.DEPTNO;

    ENAME, DEPTNO LOC

    ---------- ------ -------------

    MILLER 10 NEW YORK

    THE 10 NEW YORK KING

    CLARK 10 NEW YORK

    FORD 20 DALLAS

    20 DALLAS ADAMS

    SCOTT 20 DALLAS

    20 DALLAS JONES

    DALLAS SMITH 20

    JAMES 30 CHICAGO

    TURNER 30 CHICAGO

    BLAKE 30 CHICAGO

    MARTIN 30 CHICAGO

    WARD 30 CHICAGO

    ALLEN 30 CHICAGO

    14 selected lines

    My doubt is both are same query is the same, is in ansi format and is in the format of the Oracle,.

    but the results are different.

    For the first query null is coming for unmatched records in the dept table

    but in the second query, it does not come

    Thank you

    Hello

    2947022 wrote:

    Hi all

    I use under version

    Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0

    SQL > SELECT E.ENAME,.

    2 D.DEPTNO,

    3 D.LOC

    4. TO EMP E,.

    DEPT 5 D

    6. WHERE = E.DEPTNO D.DEPTNO (+);

    ENAME, DEPTNO LOC

    ---------- ------ -------------

    DALLAS SMITH 20

    ALLEN 30 CHICAGO

    WARD 30 CHICAGO

    20 DALLAS JONES

    MARTIN 30 CHICAGO

    BLAKE 30 CHICAGO

    CLARK 10 NEW YORK

    SCOTT 20 DALLAS

    THE 10 NEW YORK KING

    TURNER 30 CHICAGO

    20 DALLAS ADAMS

    JAMES 30 CHICAGO

    FORD 20 DALLAS

    MILLER 10 NEW YORK

    40 BOSTON

    15 selected lines

    -----------------------------------------------------------------------------------------------------------------------------

    SQL > SELECT E.ENAME,.

    2 D.DEPTNO,

    3 D.LOC

    4. TO EMP E

    5 LEFT OUTER JOIN

    D 6 DEPT

    7. THE E.DEPTNO = D.DEPTNO;

    ENAME, DEPTNO LOC

    ---------- ------ -------------

    MILLER 10 NEW YORK

    THE 10 NEW YORK KING

    CLARK 10 NEW YORK

    FORD 20 DALLAS

    20 DALLAS ADAMS

    SCOTT 20 DALLAS

    20 DALLAS JONES

    DALLAS SMITH 20

    JAMES 30 CHICAGO

    TURNER 30 CHICAGO

    BLAKE 30 CHICAGO

    MARTIN 30 CHICAGO

    WARD 30 CHICAGO

    ALLEN 30 CHICAGO

    14 selected lines

    My doubt is both are same query is the same, is in ansi format and is in the format of the Oracle,.

    but the results are different.

    For the first query null is coming for unmatched records in the dept table

    but in the second query, it does not come

    Thank you

    In fact, these requests are not the same.

    The first is to find all the lines of the Department, with the corresponding lines of PGE (when there are).  This is equivalent to «FROM dept LEFT OUTER JOIN emp...» ».

    The second is to find all the rows in the emp of the lines of the Department (when there are any).  This is equivalent to «...» WHERE e.deptno = d.deptno (+).

  • Bad result in a left outer join in 12.1.0.2

    Hallo,

    We discovered a strange behaviour in a query. The query provides values in a column of outer join where there is no corresponding value in the table is attached to the outside.

    When you expand this request by the "ORDER BY" then this query gives the correct result.

    Example:

    SQL > desc tb_a
    Name                                Null?    Typ
    -------------------------------------------- ----------------------------
    ID NOT NULL NUMBER (19)

    SQL > desc tb_b
    Name                                Null?    Typ
    -------------------------------------------- ----------------------------
    CLOSED NOT NULL NUMBER (1)
    ID NOT NULL NUMBER (19)

    CCS_APPLICATION@icw01> select * from tb_a where id in (4148,4141,4195);

    ID
    ----------
    4148
    4141
    4195

    CCS_APPLICATION@icw01> select * from tb_b where id in (4148,4141,4195);

    INTERNAL ID
    ---------- ----------
    4148 0

    CCS_APPLICATION@icw01> SELECT
    2      b.id                            AS b_id,
    3      a.id                            AS a_id,
    4 b.closed AS b_closed
    5
    6 tb_a a
    7 LEFT OUTER JOIN tb_b b ON a.id = b.id
    8 WHERE a.id IN (4148, 4195, 4141)
    9 ORDER BY ASC a.id
    10;

    B_ID ALLOCATION A_ID B_CLOSED
    ---------- ---------- ----------
    4141
    4148 4148 0
    4195

    CCS_APPLICATION@icw01> SELECT
    2      b.id                            AS b_id,
    3      a.id                            AS a_id,
    4 b.closed AS b_closed
    5
    6 tb_a a
    7 LEFT OUTER JOIN tb_b b ON a.id = b.id
    8 WHERE a.id IN (4148, 4195, 4141)
    9 - ORDER BY ASC a.id
    10;

    B_ID ALLOCATION A_ID B_CLOSED
    ---------- ---------- ----------
    4148 4148 0
    4141 4141
    4195 4195

    instance parameter:

    VALUE OF TYPE NAME

    ------------------------------------ ----------- ------------------------------

    compatible string 12.1.0.2.0

    optimizer_features_enable string 12.1.0.2

    After ""alter system set optimizer_features_enable = ' 11.2.0.4 ';"  the query provides the correct result in both cases (ordered and unordered).

    Now the final question: is this a bug?

    1480970 wrote:

    Hallo!  Yes, I searched the Support of Oracle. I found some similar entries, but not an exact match. To fix some issues

    with 12.1.0.2.

    There is another interesting clue when look you on the execution plan:

    Note

    -----

    -the dynamic statistics used: dynamic sampling (level = 2)

    - This is an adaptation plan

    We have disabled (= FALSE) optimizer_adaptive_features and the query provides the correct values.

    This could be a solution for us.

    Looks like a pretty tight match for bug 18430870, even if it affects the two 12.1.0.1 and 12.1.0.2, which contradicts the Martin trial against 12.1.0.1.

    The description of the bug mentions disabling "_projection_pushdown" (set to false) should also be a viable solution, perhaps if you want to give that a try and see if it is a different bug or not.

    There are also a number of one-time fixes already available for download, maybe your version / platform is already covered, if the bug applies.

    Randolf

Maybe you are looking for

  • 'iPhone has been severely infected by viruses -' is this possible?

    Surf the internet (safari) pops up a window that says that the iPhone has been severely infected by viruses (respectively 7) and I have to follow the instructions to repair the phone. Is this possible or is it a fake? JavaScript:;

  • event

    We can link a case of event in a VI to control over another VI or a global variable in the same project? I have a VI of high level that has leave and abandon the buttons inside.  Instead of copying these buttons in all the others, popup screws would

  • Help please with activation Windows 7 Ultimate

    Diagnostic report (1.9.0027.0):-----------------------------------------Validation of Windows data--> Validation code: 50Code of Validation caching online: 0x0Windows product key: *-* - YG69F - 9M66D-PMJBMThe Windows Product Key hash: /kehptF9HHVxM5d

  • the top row of the keyboard of my laptop has symbols and the F keys.

    How to switch between or set the default value to the F keys?

  • Flash Player installed on Samsung GT N7000

    I have old wife and deaf is my first BSL is a way more Visual than Word to understand.My 4 years mobile Flash Player have more come in last 2 years ago adobe stopped I don't know why? Done not right Adobe stop deaf need all Visual access all the vide