Left outer join query and check the status

Hello

I have two tables as tables below

table_1

MI_ACC_IDENTIFIERCHARGE_START_DATECHARGE_END_DATEPBA_INT_AMT
200000000001 SEP-05 00.00.0029 SEP-05 00.00.000.26
200000000030 SEP-05 00.00.0031 OCTOBER 05 00.00.001.92
20000000001 NOVEMBER 05 00.00.00NOVEMBER 30 05 00.00.000.34
20000000001 AUGUST 06 00.00.0031 AUGUST 06 00.00.000.47
200000000031 MARCH 06 00.00.0027 APRIL 06 00.00.000.34
200000000030 DECEMBER 05 00.00.0031 JANUARY 06 00.00.001.92
20000000001 MARCH 05 00.00.0031 MARCH 05 00.00.000.26

Table_2

MI_ACC_IDENTIFIERCHARGE_START_DATECHARGE_END_DATETOT_INT_AMT_OVER_25P
200000000030 SEP-05 00.00.0031 OCTOBER 05 00.00.000
20000000001 NOVEMBER 05 00.00.00NOVEMBER 30 05 00.00.000.81756
20000000001 DECEMBER 05 00.00.0029 DECEMBER 05 00.00.000.64724
200000000030 DECEMBER 05 00.00.0031 JANUARY 06 00.00.005.51555

Power required:

MI_ACC_IDENTIFIERCHARGE_START_DATECHARGE_END_DATENVL(B.PBA_INT_AMT,0)TOT_INT_AMT_OVER_25P
20000000001 NOVEMBER 05 00.00.00NOVEMBER 30 05 00.00.000.340.81756
200000000030 DECEMBER 05 00.00.0031 JANUARY 06 00.00.001.925.51555
20000000001 DECEMBER 05 00.00.0029 DECEMBER 05 00.00.0000.64724

I have to check if TOT_INT_AMT_OVER_25P > B.PBA_INT_AMT and also required to display if there is no matching record in table_1 and exist in table_2 then display as well

Queries for the table:

CREATE TABLE 'TABLE_1 '.

(

ACTIVATE THE "MI_ACC_IDENTIFIER" NUMBER (10,0) NOT NULL,

DATE OF THE "CHARGE_START_DATE."

DATE OF THE "CHARGE_END_DATE."

NUMBER (15.2) "PBA_INT_AMT".

);

Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date ('01 - SEP - 05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (29-SEP-05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.26);

Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (30-OCT-05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 October 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 1.92);

Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (1 November 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (30 November 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.34).

Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (1 August 06 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 August 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.47);

Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (31 March 06 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (27 April 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.34).

Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (30 December 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (31 January 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 1.92);

Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (1 March 05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 March 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.26);

CREATE TABLE 'TABLE_2.

(

ACTIVATE THE "MI_ACC_IDENTIFIER" NUMBER (10,0) NOT NULL,

DATE OF THE "CHARGE_START_DATE."

DATE OF THE "CHARGE_END_DATE."

"TOT_INT_AMT_OVER_25P" NUMBER (15.5)

);

Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (30-OCT-05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 October 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0);

Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (1 November 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (30 November 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.81756);

Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (1 December 05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (29 December 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.64724);

Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (30 December 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (31 January 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 5.51555);

Query, I used:

SELECT A.MI_ACC_IDENTIFIER, A.CHARGE_START_DATE, A.CHARGE_END_DATE, NVL (B.PBA_INT_AMT, 0), a.TOT_INT_AMT_OVER_25P OF
TABLE_2 A, B FROM TABLE_1
WHERE A.MI_ACC_IDENTIFIER = B.MI_ACC_IDENTIFIER (+)
AND A.CHARGE_START_DATE = B.CHARGE_START_DATE (+)
AND A.CHARGE_END_DATE = B.CHARGE_END_DATE (+)
and A.TOT_INT_AMT_OVER_25P > B.PBA_INT_AMT (+);

I have been using the syntax of ANSI join for some time. They are readable and code looks more elegant. A reason do not want to use it?

I don't care

SQL> select t2.mi_acc_identifier
  2       , t2.charge_start_date
  3       , t2.charge_end_date
  4       , nvl(t1.pba_int_amt, 0) pba_int_amt
  5       , t2.tot_int_amt_over_25p
  6    from table_1 t1
  7       , table_2 t2
  8   where t1.mi_acc_identifier (+)= t2.mi_acc_identifier
  9     and t1.charge_start_date (+)= t2.charge_start_date
 10     and t1.charge_end_date   (+)= t2.charge_end_date
 11     and (t1.pba_int_amt < t2.tot_int_amt_over_25p     or t1.mi_acc_identifier is null);

MI_ACC_IDENTIFIER CHARGE_ST CHARGE_EN PBA_INT_AMT TOT_INT_AMT_OVER_25P
----------------- --------- --------- ----------- --------------------
       2000000000 01-NOV-05 30-NOV-05         .34               .81756
       2000000000 30-DEC-05 31-JAN-06        1.92              5.51555
       2000000000 01-DEC-05 29-DEC-05           0               .64724

SQL>

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

  • Get the error invalid identifier in the left outer join

    I wrote a query and get the invalid identifier error during execution:
    the exact error is: ORA-00904: "D". "" ACCT_NO ": invalid identifier
    This query is not able to access the parent table alias in the subquery of the left outer join.

    This is the query:
    SELECT D.PROD_DESC_TX, BASE. ASSET_NUM, BASE. PROD_ID, BASE.NAME
    OF TABLE1 D
    LEFT OUTER JOIN
    (
    SELECT ASSET_NUM, PROD_ID, B.SID
    FROM TABLE2 E
    JOIN IN-HOUSE TABLE3 HAS IT E.PROD_ID = A.ROW_ID
    JOIN INTERNAL TABLE 4 C ON A.PAR_PROD_INT_ID = C.ROW_ID
    INTERNAL TABLE5 JOIN B ON C.ROW_ID = B.PAR_ROW_ID
    AND B.TYPE = 'VALUE '.
    AND B.NAME = 'VALUE '.
    WHERE E.ASSET_NUM = ((CASE WHEN LTRIM (RTRIM (D.BANK_NO)) = '021 ' THEN '021' ELSE ' 020' END) |) LTRIM (RTRIM (D.APPL_CD)). LTRIM (RTRIM (D.ACCT_NO)))
    ) BASE ON ((CASE WHEN LTRIM (RTRIM (D.BANK_NO)) = '021 ' THEN '021' ELSE ' 020' END) |) LTRIM (RTRIM (D.APPL_CD)). LTRIM (RTRIM (D.ACCT_NO))) = BASE. ASSET_NUM
    WHERE D.BANK_NO = 'VALUE '.
    AND D.APPL_CD = 'VALUE '.
    AND D.ACCT_NO = 'VALUE '.

    Edited by: user648525 13 Sep, 2011 01:21

    I can easily look at your request at this time (using my iPhone on a train).

    But trying out this line in the WHERE (the one with the invalid reference) clause in the main query.

    Who is... in the view of inline, use only the logic of the join (the clauses).

    Overflow the filtering logic (WHERE clause) to the main request. You may need to select some additional inline view columns to make these references work.

  • 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.

  • 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.

  • Check the status of voice on the 4.0 unit cards (3)

    Hello

    I would like to know how can I test if the voice cards are correctly installed and setup of the unit has completed the installation of the voice card successfully?

    As far as I know is to open the DCM program and check the status of each voice card. Are there other means or tools to check voice cards in more detail?

    Moreover, I found the in Device Manager, the server could only recognize the cards as the unknown PCI devices. Is this normal?

    Thank you

    ---

    Ray

    DCM confirms that the card has been properly installed.

    Regarding the unknown PCI error, it is normal.

    "Note that if you view a voice card using the Windows Device Manager, the card can be displayed as an unknown device PCI with a warning indicating that the drivers for the device are not installed. A found new hardware wizard may also appear for each card during installation or to restart the computer in Cisco Unity. These conditions are the two expected behavior and do not indicate an error or a condition requiring action. You can disable the hardware detected Wizard to prevent it from appearing at restarting the Cisco Unity computer."

    http://www.Cisco.com/en/us/products/SW/voicesw/ps2237/products_installation_guide_chapter09186a00801ba4b6.html#1505050

    H. M.

  • How to check the status of the import in Windows?

    Hello

    Import runs in my box of Wndows. The log file is not updated since long. How to check the status of the import job? FYI its oracle 10g.

    And I checked the database which.

    FYI
    ===
    Select * from DBA_DATAPUMP_SESSIONS;

    no selected line.

    Select * from DBA_JOBS_RUNNING;

    no selected line


    Select the username, machine, module, sid, State, event, seq #, session seconds_in_wait $ v where type <>'IMPORT' and username = "AUTOTIME";

    no selected line



    Please let me know.

    You actually look at the session of $ v and check the status of the session that is created by the import job.

    Sometimes the underlying tablespace is full, so import session just hangs, it must increase the size of the storage space.

    You should also look at alert.log file and see if there is any error message like "cannot extend table space '.

  • left outer join and the where clause for the table to the right

    I want to join two tables a and b, where a is a must and b is a result set in option. When I use a left outer join to a to b, I want to achieve:

    1. Select a single column, two columns of b (not the join columns)
    2 - even if theres no friendly on the join column does not return data from one.
    3. If there is a match applies when the criteria on column b (table in option)

    so, how can I avoid no_data_found in this case? When I apply where criteria for b, so it does not return the data from one, which is a must.

    Sounds like a regular outer join to me...

    select a.col1, b.col2, b.col2
    from   tableA a
           left outer join tableB b
           on (a.id = b.id and b.colX = 'X')
    
  • 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> 
    
  • 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,

    ^_^

  • 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.

  • 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
    
  • Query of queries: error when you try to fake Left Outer Join

    Hello

    I'm trying to reproduce a left outer join, combining two query of queries using a method I find here

    However, I get an error message...

    Here is the code I use...

    < cfquery dbtype = "query" name = "qry" >
    SELECT *.
    OF returnQry, returnQry2
    WHERE returnQry.mediumImage = returnQry2.mediumImage
    ORDER BY returnQry.name
    < / cfquery >

    < name cfquery = "returnQry3", dbtype = "#application.mx #" >
    SELECT *.
    OF trackmeanings t
    < / cfquery >

    < cfquery dbtype = "query" name = "endQry" >
    SELECT name, nameRcd, mediumImage, comments COUNT (sMessage)
    OF qry, returnQry3
    WHERE qry.name = returnQry3.sNameTrack

    UNION

    SELECT name, nameRcd, mediumImage, comments COUNT (sMessage)
    OF qry, returnQry3
    WHERE #qry.name # NOT IN (#QuotedValueList (returnQry3.sNameTrack) #)
    GROUP BY name, nameRcd, mediumImage
    < / cfquery >

    When I try to use the query output in a page, I get the error message "incorrect conditional expression, waiting for an a [as |]» null | between | in | "comparison condition.

    Anyone have any ideas?

    Thank you very much

    The items in the list should be cited.  Since you are using quotedvaluelist, it's weird that they aren't.  However, if you use cfqueryparam, list = Yes, you should have better luck.  Among other things, it will protect you against the apostrophe in names.

  • LEFT OUTER JOIN, trigger after QUERY problem

    Hello

    Guide to please the following

    I wrote under query in QUERY after a BLOCK of TABULAR DATA, not as a single text element, called INVENTORY_ITEM

    Select c.cat |' '|| s.SubCat |' '|| L1.lvl1 POINT IN: DATABLOCK. INVENTORY_ITEM
    of itemcat c
    LEFT OUTER JOIN itemsubcat s on (c.catid = s.catid)
    LEFT OUTER JOIN lvl1 l1 on (s.subcatid = l1.subcatid)

    When I compile the module an error is generated

    «* ' Met the 'LEFT' symbol when waiting for one of the following values for the group with intersect less order start union where connect '.» *

    Top query works fine with ORACLE SQL DEVELOPER.

    Any solution please.

    Kind regards

    Difference

  • OUTER JOIN query returns the results of JOIN IN-HOUSE 11.2.0.1.0

    I'm data transfer in 11.2.01.0 (Windows XP 32-bit) and I wanted to compare the sizes of table with the same Table name in two different patterns, ML and SILENT, with a FULL OUTER JOIN (to account for all the tables and NULL values in a diagram).

    The scheme of ML has 176 tables: schema TUT a 133 tables. The use of a standard INNER JOIN gives 131 paintings.

    I get precisely the results with a FULL OUTER JOIN I get with an INTERNAL JOIN (not the same NULL values so I know they exist).

    This happens in SQL-Plus, SQL_Developer and using Oracle Wire pilot of Data_Direct.

    Here is the code:

    Login: SYS as SYSDBA or SYSTEM (same results for either)

    SELECT M.TABLE_NAME, M.NUM_ROWS, T.TABLE_NAME, T.NUM_ROWS
    OF SYS. ALL_TABLES M FULL OUTER JOIN SYS. ALL_TABLES T ON M.TABLE_NAME = T.TABLE_NAME
    WHERE
    M.OWNER = 'ML' AND
    T.OWNER = 'TUT';

    Produce the same results with LEFT OUTER joins and RIGHT OUTER joins in ASI and Oracle (+) syntax.

    Any thoughts?

    Hello

    If you read what I posted, forget it. MScallion (below) gave the correct answerr.

    If conditions such as

    owner   = 'ML'
    

    in the WHERE clause, and then they will reject the rows of the result set formed by the join condition.

    The inner join returns only 131 lines where the two 'paintings' have the same table_names.
    The outer joins return multiple lines (133, 176 or 178) before the place WHERE the provision is applied , but the WHERE clause eliminates all lines except the 131 found by the inner join.

    Published by: Frank Kulash, July 10, 2010 14:23

Maybe you are looking for

  • backup 4th gen Apple tv

    Hey guys, I was wondering if someone knows a way to backup saves the settings/configuration/game (I suspect saved game could land in the center of games but I have not yet tested this theory) on an ATV 4? I had a peek in iTunes and Apple Configuratio

  • Pavilion 15-n248sa: what processor speed is shown on the information sheet?

    I was recently going through all my stuff, work on which should be placed in a cell, when I found all the information about my computer sheets. On one of these journals, it says that I have an Intel Pentium Quad - Core 2.4 GHz processor N3520, but wh

  • HP color laserjet CP2025: no color since the Win10 update

    My Win10 system updated itself lastnight version 1607 (build 1439.82). Before the CP2025 (network printer) worked well. Since the update, she refuses to print in color. (Built-in menu CP2025 printed) demonstration page is fine: full color Windows all

  • WindowsXP Professional SP1___version 2002__

    I have Windows XP Professional version 2002 SP1 Download Windows XP Professional SP1a? My product key will work?

  • ea6300 and CA 580 - unable to connect at 5 GHz - solved

    Using an EA6300 and a 580 AC usb adapter, trying to maximize the speed on a single computer for audio and video streaming. In 5 GHz settings so I put the following mode network - CA only security mode - wpa2/wpa mixed/personal Channel - auto Channel