Effective way to manage multiple outer joins

I have a large refcursor currently being returned by an oracle 11g stored procedure.  I need to add some addiotional columns to the record set before it is returned.   The logic to include new columns is not simple, and I have to WITH instructions to store the new columns.  In total, I will have to WITH that contains results that are currently returned and 5 additional STATEMENTS that each contain an id column to join to the existing set of records and the new column.  My question is, how I left outer join the Recordset existing (with id column) with each of the 5 WITH statement queries to include the new 5 column in the original dataset?

example:

WITH orginalresults AS)

SELECT id,

col1,

col2

...

)

WITH newcol1 AS)

SELECT id,

newcol1

)

WITH newcol2 AS)

SELECT id,

newcol2

)

Join them

Select. *, newcol1.newcol1, newcol2.newcol2, newcol3.newcol3, newcol4.newcol4...

of orginalresults

outer join newcol1 left orginalresults user.user = newcol1.id

outer join newcol2 let originalresults.id = newcol2.id

outer join newcol3 let originalresults.id = newcol2.id

outer join newcol4 let originalresults.id = newcol4.id

.....

I'll have to repeat joins five times.   This approach is valid?  Is there a better way to do it?

Hello

what I understand: what about something like:

WITH original_set AS

(SELECT LEVEL Id

OF the double

CONNECT BY LEVEL<=>

)

an ACE

(SELECT id, "one" |) Col1 to_char (id)

Of original_set

WHERE id IN (1, 4)

)

two ACEs

(SELECT id, 'two' |) Col2 to_char (id)

Of original_set

WHERE id IN (1, 2)

)

three ACEs

(SELECT id, 'three' |) Col3 to_char (id)

Of original_set

WHERE 1 = 2 / * empty * /.

)

four ACEs

(SELECT id, 'four' |) Col4 to_char (id)

Of original_set

WHERE id IN (3, 4)

)

five ACEs

(SELECT id, 'five' |) Col5 to_char (id)

Of original_set

ID WHERE = 2

)

SELECT os.id, o.col1, tw.col2, th.col3, fo.col4, fi.col5

To original_set os

A LEFT OUTER JOIN o ON o.id = os.id

LEFT OUTER JOIN two tw ON os.id = tw.id

E three LEFT OUTER JOIN ON os.id = th.id

LEFT OUTER JOIN four fo WE os.id = fo.id

LEFT OUTER JOIN five fi WE os.id = fi.id

ORDER BY id

;

ID COL1 COL2 COL3 COL4 COL5

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

1 one1 two1

2 two2 five2

3                         four3

4 one4 four4

5

But the same thing can be achieved with:

WITH original_set AS

(SELECT LEVEL Id

OF the double

CONNECT BY LEVEL<=>

)

SELECT os.id

CASE WHEN os.id IN (1, 4)

THEN 'a ' | To_char (id)

END col1

CASE WHEN os.id IN (1, 2)

THEN 'two ' | To_char (id)

END col2

CASE WHEN 1 = 2

THEN "three" | To_char (id)

END col3

CASE WHEN os.id IN (3, 4)

THEN "four". To_char (id)

END col4

CASE WHEN os.id = 2

THEN "five" | To_char (id)

END col5

To original_set os

ORDER BY id

;

(I mean: I just do a select on the main table and include the logic of 'creation' of the five 'WITH' tables directly in the select; see how this can be applied to your real situation)

HTH,

Bruno Vroman

Tags: Database

Similar Questions

  • Best way to manage multiple windows help

    Hi all:

    I work with X 5 to create help for a large modular application. I have a single aid project, but want to deliver content for help only for the specific modules used by clients. I am attemtping to create multiple windows help with a window main containing helps for deliverables standard and other windows containing help for specific modules. What is the best way to achieve this using a single project. Or do I have to maintain several projects?

    I tried to use custom windows, but there are some limitations. I created a new file for a custom hhc window manually and it works fine. But I can't open the custom window by clicking on a book in the table of contents (which are what I want) the main window, but can do so by clicking on a subject. Also, I can't assign topics by separate default for each custom window. In addition, when I click a hyperlink in a custom window that links to a topic in the main window, the theme of the main window display in the custom window but it is not in the table of contents of the custom window, it's awkward.

    Help, please!
    Romeo Coutinho

    From the point of view of the user a merged set of help files is probably the best solution. Use global windows of the comprehensive help system is displayed in a window and displays only the topics for modules installed (if you can get your installation meets your wishes people that is ;-)).

    Several projects handling is more complicated to manage a large. Each help topic only stops in a single project; If you want to create or update the help for the XYZ_1 module, you open the project XYZ_1. If you want to change something in the master project, you open the master project. After the edition of a project, you simply compile this module and nothing else.

    The only thing you need to learn are the peculiarities of the help compiler about merged projects. See http://www.helpware.net/htmlhelp/how_to_merge.htm for a good description of these folds.

    -Dirk Bock

  • Full outer join

    30%

    Hello

    I have a few questions to ask. Please see below I have provided a script to recreate my problem.

    Question 1.

    I have the following query does not work when I include columns (see 1.2) in the select but will run when I use the Asterix symbol (see 1.1)

    * 1.1 runs with no problems *.
    select *
      from ora full outer join txt on ora.ora_id_y = txt.txt_id_y;
    * 1.2 returns error.*
    select txt.txt_id_y
         , txt.txt_n
         , txt.txt_y
         , ora.ora_n
         , ora.ora_y
      from ora full outer join txt on ora.ora_id_y = txt.txt_id_y;
    
    Error report:
    SQL Error: ORA-00918: column ambiguously defined
    00918. 00000 -  "column ambiguously defined"
    *Cause:    
    *Action:
    Question 2.

    Is it possible to use a query with joins free and using multiple outer joins to accomplish what I have under which is seen 6 to access the query I have to Question 1.

    CREATE THE SCRIPT
    drop table master;
    
    create table master
    ( id varchar2 (10 char)
    , txt varchar2 (1 char)
    , ora varchar2 (1 char)
    );
    
    INSERT INTO MASTER (ID, TXT, ORA) VALUES ('orange' , 'Y', 'Y');
    INSERT INTO MASTER (ID, TXT, ORA) VALUES ('apple', 'Y', '');
    INSERT INTO MASTER (ID, TXT, ORA) VALUES ('orange'  , 'Y', 'N');
    INSERT INTO MASTER (ID, TXT, ORA) VALUES ('peach'  , 'Y', '');
    
    create or replace force view ora_n
    as
    select id
         , count (ora) ORA_N
      from master
     where ora in ('N')
     group by id;
    
    create or replace force view ora_y
    as
     select id
         , count (ora) ORA_Y
      from master
     where ora in ('Y')
     group by id;
    
    create or replace force view txt_n
    as 
     select id
         , count (txt) TXT_N
      from master
     where txt in ('N')
     group by id;
    
    create or replace force view txt_y
    as 
     select id
           , count (txt) TXT_Y
      from master
     where txt in ('Y')
     group by id;
     
    create or replace force view ora
    as 
    select ora_n.id ora_id_n
         , ora_y.id ora_id_y
         , ora_n.ora_n
         , ora_y.ora_y
      from ora_n full outer join ora_y on ora_n.id = ora_y.id;
    
    create or replace force view txt
    as 
    select txt_y.id txt_id_n
         , txt_y.id txt_id_y
         , txt_n.txt_n
         , txt_y.txt_y
      from txt_n full outer join txt_y on txt_n.id = txt_y.id; 
    Published by: benton on August 21, 2012 10:48

    Published by: benton on August 21, 2012 11:11

    Found: support for Oracle, there are:

    Bug 6319169 : ORA-918, FULL OUTER JOIN
    Reproduced on 10.2.0.1,10.2.0.3.
    Fixed to the product Version 11.0
    WORKAROUND solution: alter session set '_column_elimination_off' = true;

  • Diff "full outer join" is going. "(+)" SELECT syntax?

    As far as I know there are two ways to set an outer join:

    Select... from tab1 external t1 full join tab2 t2 on t1.id = t2.id;
    or:
    SELECT... from tab1 tab2 t2, t1 where t1.id = t2.id (+)

    They are absolutely equivialent?

    Who are the most common one?

    Who serve as well on other databases (DB2, MySQL)?

    Can I put an additional WHERE clause at the end of the first statement:

    SELECT... from tab1 t1 outer join t2 on t1.id = t2.id tab2 complete WHOSE...;

    Select... from tab1 external t1 full join tab2 t2 on t1.id = t2.id;

    It's FULL OUTER JOIN

    SELECT... from tab1 tab2 t2, t1 where t1.id = t2.id (+)

    It's LEFT OUTER JOIN.

    They are quite different.

    FULL OUTER JOIN - retrieves all the rows from tab1 and tab2

    LEFT OUTER JOIN - gets all the tab1 and lines than the line that matches the join condition of tab2.

    Here is a simple test.

    create table tab1(id integer)
    /
    create table tab2(id integer)
    /
    begin
      insert into tab1 values(1);
      insert into tab1 values(2);
      insert into tab1 values(3);
    end;
    /
    begin
      insert into tab2 values(3);
      insert into tab2 values(4);
      insert into tab2 values(5);
    end;
    /
    Select t1.id, t2.id
      from tab1 t1 full outer join tab2 t2
        on t1.id =t2.id
    /
    Select t1.id, t2.id
      from tab1 t1, tab2 t2
     where t1.id = t2.id(+)
    /
    

    Run it and see the result.

  • How to specify an outer join in the query designer

    I quickly built a large query with the query designer, and it works very well, but does not produce 9 disks on 2200 - so I need to change to an outer join.

    My problem is that I can't find a way to specify an outer join. I tried to change the query, query builder formed, but it won't let me.

    I know that I can capture the query, edit and run it in sql developer and that works fine, but I want to use the Query Builder as it is the fastest way I know to quickly add and remove items - my users don't know exactly what that it to include.

    I know it's kind of a trivial question, but I searched the forum, manual, the web and no luck

    Thanks for any help you can give

    Glenn

    Hi Glenn,.

    When you use the query designer to create the sql statement, you must click on the empty box to the right of the fields in each table to create the join. When you are finished, you should see a line drawn between the two tables. Click on this line, and a small window appears allowing you to select inner outer or right outer joins, left.

    When the report was created, however, you must change the statement. For example, if you use the query designer to join DEPT at EMP based on the DEPTNO field on the two tables, you get:

    select      "DEPT"."DEPTNO" as "DEPTNO",
          "DEPT"."DNAME" as "DNAME",
          "DEPT"."LOC" as "LOC",
          "EMP"."EMPNO" as "EMPNO",
          "EMP"."ENAME" as "ENAME",
          "EMP"."JOB" as "JOB",
          "EMP"."MGR" as "MGR",
          "EMP"."HIREDATE" as "HIREDATE"
     from      "EMP" "EMP",
          "DEPT" "DEPT"
     where   "DEPT"."DEPTNO"="EMP"."DEPTNO"
    

    This is to change:

    select      "DEPT"."DEPTNO" as "DEPTNO",
          "DEPT"."DNAME" as "DNAME",
          "DEPT"."LOC" as "LOC",
          "EMP"."EMPNO" as "EMPNO",
          "EMP"."ENAME" as "ENAME",
          "EMP"."JOB" as "JOB",
          "EMP"."MGR" as "MGR",
          "EMP"."HIREDATE" as "HIREDATE"
     from      "EMP" "EMP"
          LEFT OUTER JOIN "DEPT" "DEPT" ON "DEPT"."DEPTNO"="EMP"."DEPTNO"
    

    Andy

  • How to manage the update/insert in display with Outer Join object?

    Hello

    I have a problem in the treatment of update/insert in the original Version that contains two EOs with right outer join. The first EO values are inserted before and I want if second values EO already exists, it will update and if not a new record created.

    Error when I commit after entering values is: ' entity line with null key is not found in SecondEO. "

    What is the solution?

    Thank you

    Hello

    Make sure that your view object, you have included the key attributes of the two entity objects.

    Kind regards

    Saif Khan.

  • Outer joins for multiple columns

    I have a data model that is simple, consisting of two dimension tables and one fact table. The fact table contains two columns of dimension and the column of a fact.

    The dimensions are time and channel (from a Global schema). The dimension in the fact table columns are months and the track, which are the lowest in their respective dimensions. The column is for sale.

    Not all combinations of time and channel data available, because our data goes back to 1998, but we don't sell through the Internet channel until 2001.

    A simple request for monthly responses, channels, and sales returns just what you would expect - only the lines that actually have data in the fact table.

    I would like to see all THE combinations of month and channel, regardless of whether or not there is a line in the fact table. I was under the impression that the definition of the join would type Left Outer in the complex join in the model diagram of Business happening. I did, as well affecting the Left Outer relations. The resulting SQL code looks like this:

    Select T68. MONTHS in the c1 form,
    T50. CHANNEL C2,
    sum (T514. Turnover) in c3,.
    T68. MONTH_END_DATE as c4
    Of
    T68 BI_D_TIME left (outer join
    Left outer join BI_D_CHANNEL T50
    BI_F_SALES T514 on T50. CHANNEL = T514. CHANNEL) on T68. MONTH = T514. MONTH
    Group of T50. CHANNEL, T68. MONTHS, T68. MONTH_END_DATE
    order of c4, c2

    Unfortunately, that SQL is not what I want it to do. It returns the same results as above - namely, only the lines that exist in the fact table. I confirmed that by running the code in SQL Developer. It returns one row for each month, but it returns a line for each combination of months and channel.

    For example, in Jan98, I get a line for the channel catalog, but not for the Internet or directly. Dec05, I get a line with Dec05 as month, NULL as the canal and of course NULL as sales. What I'd like TO see for each month is three lines, each line containing one of the three values of channel, if this month/channel combination had no sale or not.

    Is it possible to change the repository to accomplish what I want to do?

    Check here how you can make densification on an environment of ROLAP
    http://gerardnico.com/wiki/dat/OBIEE/bi_server/design/obiee_densification

    See you soon
    Nico

  • Manage multiple windows or applications

    is there a way to have four apps display in the task view this quad of the screen instead of split the screen in half, it would be to divide the screen into four

    Hello

    Help windows 10 - wink

    http://winsupersite.com/Windows-10/how-master-Windows-10-snap-assist-desktop-mode

    Press the Windows key + Tab to see the 3D Flip effect

    Use the arrow keys to navigate between windows

    How

    http://www.howtogeek.com/198230/how-to-use-snap-assist-and-2x2-snap-on-Windows-10/

    Windows Vista - Flip 3D

    http://Windows.Microsoft.com/en-us/Windows-Vista/using-Windows-Flip-3D

    Manage multiple windows - Windows 7

    http://Windows.Microsoft.com/en-us/Windows/manage-multiple-Windows#1TC=Windows-7

  • outer join with the additional constraint

    Hello

    With the help of Oracle 11 g R2.

    I would of outer join tables 2 together and put down restrictions on the types of records that are returned in the query result. Here's a mock-up of the tables and data.

    create table aaa (col1 number not null, col2 number not null)

    create table bbb (col1 number not null, col2 number not null)

    insert into values of aaa (1: 80)

    insert into values aaa (2, 90)

    insert into values aaa (3, 80)

    insert into values aaa (4, 90)

    insert into values aaa (5, 80)


    insert into bbb values (3, 600)

    insert into values of bbb (4, 700)

    This is the query

    
    select a.col1, a.col2, b.col1, b.col2
    from aaa a, bbb b
    where a.col1 = b.col1 (+)
    and   (a.col2, b.col2) <> ((90, 700))
    

    The result of the query is as follows.

    col1 col1 col2 col2

    1 80

    3 80 3 600

    5 80

    Where col1 = 4 has been deleted, which is an expected result. However, where col1 = 2 has also been removed, which is not a desired outcome. Your response is appreciated.

    Hello

    Here is a way that works for the given sample data:

    SELECT *.

    AAA a

    LEFT OUTER JOIN bbb b ON a.col1 = b.col1

    WHERE the NVL (a.col2, 0) <> 90

    OR NVL (b.col2, 0) <> 700

    ;

    I don't know if that will satisfy your requirements with other data, since you didn't say what your needs are.

    Whenever you have a WHERE clause is applied after the outer join, all columns of the table in option (table bbb in this example) must be used in an NVL, NVL2 or something like a CASE expression that takes into account null values; otherwise, the effect will be the same as an inner join.

  • Partition outer join

    Hello

    I want a report that shows data for all combinations of dimensions, although in fact no data exists for them.

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e10578/tdpdw_sql.htm#TDPDW0072
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Here's my data model, inventory with a status as 'sold out' or 'available' and the designer of the element
    DROP TABLE inventory
    /
    DROP TABLE inv_status
    /
    DROP TABLE designer
    /
    CREATE TABLE inv_status(
         id          NUMBER  PRIMARY KEY
        ,description VARCHAR2(12)
        )
    /
    CREATE TABLE designer(
         id          NUMBER  PRIMARY KEY
        ,name        VARCHAR2(12)
        )
    /
    CREATE TABLE inventory(
         id          NUMBER  PRIMARY KEY
        ,fk_ist      NUMBER
            CONSTRAINT fk_inv_status
            REFERENCES inv_status (id)
        ,fk_des      NUMBER
            CONSTRAINT fk_designer
            REFERENCES designer (id)
        ,name        VARCHAR2(20)
        ,description VARCHAR2(12)
        )
    /
    and some examples of data
    INSERT INTO inv_status (id,description) VALUES (25,'sold out');
    INSERT INTO inv_status (id,description) VALUES (26,'available');
    INSERT INTO inv_status (id,description) VALUES (27,'comming soon');
    INSERT INTO inv_status (id,description) VALUES (28,'not in use');
    
    INSERT INTO designer (id,name) VALUES (111,'Marco');
    INSERT INTO designer (id,name) VALUES (112,'Tommy');
    INSERT INTO designer (id,name) VALUES (113,'Daisy');
    INSERT INTO designer (id,name) VALUES (114,'Laura');
    
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (1,25,112,'moon boot','k');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (2,25,113,'high heel','r');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (3,26,114,'sandal','f');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (4,26,113,'flip-flop','u');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (5,27,112,'horseshoe','j');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (6,27,114,'magic pair of boots','o');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (7,27,113,'runner','r');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (8,27,112,'loafer',NULL);
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (9,27,113,'climbing spur',NULL);
    COMMIT;
    I need a simple outer join to find each status as well as the objects (if available)
    SELECT  ist.id ist
           ,inv.id
           ,inv.name
           ,ist.description
    FROM    inv_status ist
            LEFT JOIN inventory inv
              ON (ist.id = inv.fk_ist)
    ORDER BY ist.id, inv.id;
    /*
    IST ID  NAME                 DESCRIPTION
    --- --- -------------------- ------------
    25  1   moon boot            sold out
    25  2   high heel            sold out
    26  3   sandal               available
    26  4   flip-flop            available
    27  5   horseshoe            comming soon
    27  6   magic pair of boots  comming soon
    27  7   runner               comming soon
    27  8   loafer               comming soon
    27  9   climbing spur        comming soon
    28                           not in use
    
    10 rows selected
    */
    The same I get with a left join partition
    SELECT  ist.id ist
           ,inv.id
           ,inv.name
           ,ist.description
    FROM    inv_status ist
            PARTITION BY (ist.id)
            LEFT JOIN inventory inv
              ON (ist.id = inv.fk_ist)
    ORDER BY ist.id, inv.id;
    /*
    IST ID  NAME                 DESCRIPTION
    --- --- -------------------- ------------
    25  1   moon boot            sold out
    25  2   high heel            sold out
    26  3   sandal               available
    26  4   flip-flop            available
    27  5   horseshoe            comming soon
    27  6   magic pair of boots  comming soon
    27  7   runner               comming soon
    27  8   loafer               comming soon
    27  9   climbing spur        comming soon
    28                           not in use
    
    10 rows selected
    */
    But what is the right partition join? Why do I have multiple lines for each State where no items exist? Or in other words: someone can tell me what I asked of the DB and it makes sense to ask him: -?
    SELECT  ist.id ist
           ,inv.id
           ,inv.name
           ,ist.description
    FROM    inventory inv
            PARTITION BY (inv.fk_ist)
            RIGHT JOIN inv_status ist
              ON (ist.id = inv.fk_ist)
    ORDER BY ist.id, inv.id;
    /*
    IST ID  NAME                 DESCRIPTION
    --- --- -------------------- ------------
    25  1   moon boot            sold out
    25  2   high heel            sold out
    25                           sold out
    25                           sold out
    26  3   sandal               available
    26  4   flip-flop            available
    26                           available
    26                           available
    27  5   horseshoe            comming soon
    27  6   magic pair of boots  comming soon
    27  7   runner               comming soon
    27  8   loafer               comming soon
    27  9   climbing spur        comming soon
    27                           comming soon
    27                           comming soon
    28                           not in use
    28                           not in use
    28                           not in use
    
    18 rows selected
    */
    For any combination of x as well as objects Designer item (if available) again a simple Cartesian product is easy to do.
    SELECT  ist.id ist
           ,des.id des
           ,inv.id
           ,inv.name
           ,ist.description
           ,des.name designer
    FROM    inv_status ist
            CROSS JOIN designer des
            LEFT JOIN inventory inv
              ON (ist.id = inv.fk_ist
                 AND des.id = inv.fk_des
                 )
    ORDER BY ist.id,des.id,inv.id;
    /*
    IST DES ID  NAME                 DESCRIPTION  DESIGNER
    --- --- --- -------------------- ------------ ------------
    25  111                          sold out     Marco
    25  112 1   moon boot            sold out     Tommy
    25  113 2   high heel            sold out     Daisy
    25  114                          sold out     Laura
    26  111                          available    Marco
    26  112                          available    Tommy
    26  113 4   flip-flop            available    Daisy
    26  114 3   sandal               available    Laura
    27  111                          comming soon Marco
    27  112 5   horseshoe            comming soon Tommy
    27  112 8   loafer               comming soon Tommy
    27  113 7   runner               comming soon Daisy
    27  113 9   climbing spur        comming soon Daisy
    27  114 6   magic pair of boots  comming soon Laura
    28  111                          not in use   Marco
    28  112                          not in use   Tommy
    28  113                          not in use   Daisy
    28  114                          not in use   Laura
    
    18 rows selected
    */
    But I just can't get with the join of LEFT or RIGHT partition
    SELECT  inv_ist.ist
           ,des.id des
           ,inv_ist.id
           ,inv_ist.name
           ,inv_ist.description
           ,des.name designer
    FROM    designer des
            PARTITION BY (des.id)
            LEFT JOIN (
                SELECT  ist.id ist
                       ,inv.fk_des
                       ,inv.id
                       ,inv.name
                       ,ist.description
                FROM    inv_status ist
                        PARTITION BY (ist.id)
                        LEFT JOIN inventory inv
                          ON (ist.id = inv.fk_ist)
                ) inv_ist
            ON (des.id = inv_ist.fk_des
               OR inv_ist.fk_des IS NULL)
    ORDER BY inv_ist.ist,des.id,inv_ist.id;
    /*
    IST DES ID  NAME                 DESCRIPTION  DESIGNER
    --- --- --- -------------------- ------------ ------------
    25  112 1   moon boot            sold out     Tommy
    25  113 2   high heel            sold out     Daisy
    26  113 4   flip-flop            available    Daisy
    26  114 3   sandal               available    Laura
    27  112 5   horseshoe            comming soon Tommy
    27  112 8   loafer               comming soon Tommy
    27  113 7   runner               comming soon Daisy
    27  113 9   climbing spur        comming soon Daisy
    27  114 6   magic pair of boots  comming soon Laura
    28  111                          not in use   Marco
    28  112                          not in use   Tommy
    28  113                          not in use   Daisy
    28  114                          not in use   Laura
    
    13 rows selected
    */
    SELECT  inv_ist.ist
           ,des.id des
           ,inv_ist.id
           ,inv_ist.name
           ,inv_ist.description
           ,des.name designer
    FROM    (
            SELECT  ist.id ist
                   ,inv.fk_des
                   ,inv.id
                   ,inv.name
                   ,ist.description
            FROM    inventory inv
                    PARTITION BY (inv.fk_ist)
                    RIGHT JOIN inv_status ist
                      ON (ist.id = inv.fk_ist)
            ) inv_ist
            PARTITION BY (inv_ist.fk_des)
            RIGHT JOIN designer des
              ON (des.id = inv_ist.fk_des)
    ORDER BY inv_ist.ist,des.id,inv_ist.id;
    /*
    IST DES ID  NAME                 DESCRIPTION  DESIGNER
    --- --- --- -------------------- ------------ ------------
    25  112 1   moon boot            sold out     Tommy
    25  113 2   high heel            sold out     Daisy
    26  113 4   flip-flop            available    Daisy
    26  114 3   sandal               available    Laura
    27  112 5   horseshoe            comming soon Tommy
    27  112 8   loafer               comming soon Tommy
    27  113 7   runner               comming soon Daisy
    27  113 9   climbing spur        comming soon Daisy
    27  114 6   magic pair of boots  comming soon Laura
        111                                       Marco
        111                                       Marco
        111                                       Marco
        111                                       Marco
        112                                       Tommy
        112                                       Tommy
        112                                       Tommy
        113                                       Daisy
        113                                       Daisy
        113                                       Daisy
        114                                       Laura
        114                                       Laura
        114                                       Laura
    
    22 rows selected
    */
    Does anyone know a simple description, something like 'Partition of outer join for Dummies

    Concerning
    Marcus

    Edited by: Marwim the 28.12.2010 09:11
    Typo

    Hey, Marcus,

    Marwim wrote:
    And that's exactly my problem: what kind of problems can I solve with outer joins partitioned?

    Programming would be much easier (and therefore less interesting and less well-paid) if it has nice, short answers to these questions.

    According to my experience, cross joins are the best when you dimension tables and partitioned outer joins are good when you don't.
    Cionsider the following partitioned outer join, which shows all the possible combinations of the job and the Department:

    SELECT       d.dname
    ,       e.deptno
    ,       e.job
    ,       e.ename
    FROM          scott.dept     d
    LEFT OUTER JOIN     scott.emp     e     PARTITION BY (e.job)
              ON     d.deptno     = e.deptno
    ORDER BY  d.deptno
    ,       e.job
    ;
    

    Output:

    DNAME              DEPTNO JOB       ENAME
    -------------- ---------- --------- ---------
    ACCOUNTING                ANALYST
    ACCOUNTING             10 CLERK     MILLER
    ACCOUNTING             10 MANAGER   CLARK
    ACCOUNTING             10 PRESIDENT KING
    ACCOUNTING                SALESMAN
    ...
    OPERATIONS                ANALYST
    OPERATIONS                CLERK
    OPERATIONS                MANAGER
    OPERATIONS                PRESIDENT
    OPERATIONS                SALESMAN
    

    It's a great use of a partitioned outer join, because there is no dimension table for employment (that is, there is no table with one line per job, which may be the target of a key foregin reference). You can use a join Cross (more an external koin) to get the same results, but it would be a subquery such as

    WITH  all_jobs  AS
    (
        SELECT DISTINCT  job
        FROM           scott.emp
    ) ...
    

    to create a table dimesnion to the fly.

    There may be exceptions. For example, if you don't have a table, but there are some jobs that actually occur in the emp table, and you want the output to include only the jobs that exist in the emp table, then the easiest thing is just to ignore the jobs table and do the partitioned outer join illustrated above.

  • Join inner &amp; outer join in a query

    I have 11 paintings, 10 tables need will always be a match on the id, table 11 may or my not have a football game. I need to print information from the 10 tables with a matching id and the information in the table 11 if a record is found.

    Help, please.

    There is nothing wrong with having 10 inner joins and 1 outer join.

    The syntax might look like this ANSII shaped:

    Of

    1Table INNER JOIN

    2table ON (1Table.key = 2Table.KEY) JOIN IN-HOUSE

    3Table ON (1Table.key = 3Table.KEY) JOIN IN-HOUSE

    4Table ON (1TAble.key = 4Table.key) JOIN IN-HOUSE

    INNER JOIN 5Tableau ON (1Table.key = 5table.key)

    6Table ON (1Table.key = 6table.key) JOIN IN-HOUSE

    INNER JOIN 7Table ON (1Table.key = 7Table.key)

    8Table ON (1Table.key = 8Table.key) JOIN IN-HOUSE

    INNER JOIN 9Table ON (1Table.key = 9Table.key)

    10Table ON (1Table.key = 10Tablekey) LEFT OUTER JOIN

    11Table ON (1Table.key = 11Table.key)

    You can use paretheses more group the results if you wish.

    When you create a relationship of this process the best resort is to do a table at the same time.

    Build the query to return properly the expected effect of the first table.  Then add the second and confirm that it is always the desired results.  Continue to add the tables one at a time, stable all along the way.

  • Full table on the right outer join scan

    Hello, I need help. Here's my query-

    SELECT / * + first_rows (100) * /.
    a.custom_gr_id, a.custom_gr_name AS customgroupname,
    a.custom_gr_type_id AS customtypeid, b.workspace_id, b.NAME, a.itime,
    a.is_shared_org AS est_partagee
    OF custom_group_pa one
    RIGHT OUTER JOIN
    account_workspace_pa b ON (a.workspace_id = b.workspace_id
    AND (a.delete_flag IS NULL or a.delete_flag <>1)
    AND a.owner_id = '123')
    WHERE b.workspace_id <>- 9999
    AND b.workspace_type_id = 1
    AND b.delete_flag = 0
    AND EXISTS (SELECT 1
    Of account_workspace_type c
    WHERE b.workspace_type_id = c.workspace_type_id)
    ITime to ORDER BY DESC;

    Account_workspace_pa almost 1 500 483 lines and custom_group_pa had 200 000 lines and account_workspace_type is a very small table of 10 lines.

    I always get a full on table account_workspace_pa table scan, while I have clues about workspace_id AND I index on workspace_id, workspace_type_id and delete_flag. The request is expected to produce less than 500 lines.

    Here's the plan I make-

    Plan
    COUNCIL of the SELECT STATEMENT: FIRST_ROWSCost: 3 931 bytes: 405 108 cardinality: 7 502
    8 SORTING ORDER BY ORDER BY a.ITIME DESCCost: 3 931 bytes: 405 108 cardinality: 7 502
    7 LOOPS IMBRIQUEES EXTERNAL (ACCOUNT_WORKSPACE_TYPE at ACCOUNT_WORKSPACE_PA) in CUSTOM_GROUP_PACost: 3 930 bytes: 405 108 cardinality: 7 502
    3 LOOPS IMBRIQUEES ACCOUNT_WORKSPACE_TYPE to ACCOUNT_WORKSPACE_PACost: 2 280 bytes: 210 056 cardinality: 7 502
    1 INDEX UNIQUE INDEX (SINGLE) ADR_DEV SCAN. SYS_C0025442 aliased as cCost: cardinality of 0 bytes: 6: 1
    TABLE 2 ACCESS FULL TABLE ADR_DEV. ACCOUNT_WORKSPACE_PA alias ADR_DEV_DATA Tablespaceb.WORKSPACE_ID b! = - 9999, b.WORKSPACE_TYPE_ID = 1 b.DELETE_FLAG = 0Cost: 2 280 bytes: 165 044 cardinality: 7 502
    VIEW 6 (Embedded SQL) cost: 0 bytes: 26 cardinality: 1
    TABLE 5 ACCESS BY INDEX ROWID TABLE ADR_DEV. Aliased as one on ADR_DEV_DATA TablespaceCost CUSTOM_GROUP_PA: 04:00 cardinality: 1
    4 INDEX RANGE SCAN INDEX ADR_DEV. IDX_CG_WSID_DF_OWID aliased as aa.delete_flag (+) is NULL, a.delete_flag (+)! = 1, a.owner_id (+) = '123', a.workspace_id (+) = b.workspace_idCost: cardinality 3: 1


    If someone can advise, why I always make a full table scan on table account_workspace_pa and what I can do to have a systematic index scan?

    Thank you.

    If you need all the lines then that would be a clue do for you?

    You don't necessarily need a full table scan. But if you have need of all ranks, it is certainly more effective to do a full scan (read through all of the blocks table in bulk, once) rather than navigate throu an index and jump from block to block to block (probably one at a time, probably having to hit most of them more than once until the work is done) after the ROWID as they occur in the index.

    Also, fully entered null will not appear in the index, so (depending on your data, NOT NULL constraints, etc.) it may be possible that navigate through an index will cause lines to be ignored.

    I think you look at that and see a problem, but the answer is: it's really the best way to accomplish what you're asking.

  • Show all dates between date range (time Dimension is left outer join)

    All,

    I did some research on this issue, but in all positions on date variables, date prompts and date filtering I have not seen one exactly to my question (perhaps that they are and I don't have my head around it properly yet).

    My requirement of report is to allow a user to select a start date and an end of day. The report is expected to show the activity of these two days - AND display 0/null on days where there is no activity. This second part is where I am getting hung up.

    The paintings in question are:
    Timedim
    EventFact
    CustomerDim

    My MDB is configured as follows:
    Left outer join of Timedim EventFact
    Inner join CustomerDim EventFact

    If I run a report by selecting the DAYS of Timedim and an EventFact measure1 with range day 01/01/2010-31/12/2010... A record for each day and it looks perfect because of the left outer join between Timedim and CustomerDim.

    But... If I add a CustomerDim field, Select TimeDim.DAY, CustomerDim.CUSTNAME, EventFact.MEASURE1, OBIEE returns only records for the days that have record EventFact.

    This is due to the fact that the Timedim is always external joined in EventFact, but adding in fact CustomerDim OBIEE set up an inner join between tables that will only return data where there are data EventFact.

    There is a way around it in this simple case, and that is to define the relationship between CustomerDim and EventFact as an outer join as well. This will give the desired effect (but an outer join between the two tables is not the real relationship) and I have add an extra dimension and add additional sources of logic to a single dimension in MDB it becomes complicated and messy.

    Also, ive ruined with the definition of the conduct in the relationship table, etc... but he gave not the desired effect.

    Has anyone ever met the need for force display all dates within a range specified with a fact table that does not have an entry for each date?

    Thanks in advance.

    K

    Published by: user_K on April 27, 2010 11:32

    Hi there, the easiest way is to the LTS himself. Double-click your LTS, go to the tab with the column mappings. Make sure you have checked "show no mapped" column.

    You should see your new dummy column in the list, in the central part of mapping (IE not the right) just enter 0, or launch the expression editor and enter 0 in there.
    simple!

  • Effective way to draw a selected graphic user

    Hello

    I channel data acquisition "n" and I need to graph data, but the channel is selected by the user. For channel 1, channel 2 or it can for example select channel 1 and 2. I have a solution to what use cases multiple structures which I know is not the best way to do it. Is there an effective way to do it. Can someone tell me a knowledge base

    I have attached the jpg to know how I do this.

    Thanks in advance

    Nitin

    You also have the visibility available field box when you view the legend of the plot. It's also can be defined by a property node.

  • The most effective way to log data and read simultaneously (DAQmx, PDM) high data rates

    Hello
     
    I want to acquire the data of several Modules cDAQ using several chassis to
    high data rates (100 k samples per second if possible). Let's say the measurement time is 10 minutes and we got a large number of channels (40 for example). The measured data is written to a PDM file. I guess, the memory or the HARD disk speed is the limits. For the user, there must be a possibility to view the selection of channels in a graph during the measurement.

    My question: what is the best and most effective way to save and read data at the same time?

    First of all, I use an architecture of producer-consumer and I don't want to write and display the data in the same loop. I expect two possibilities:

    [1] to use the 'DAQmx configure logging.vi' with the operation 'journal and read' to write the data to a PDM file. To display the data in a second loop, I would create a DVR samples documented and 'sent' the DVR for the second loop, where the data will be displayed in a graph (data value reference). This method has the disadvantage that the data of all channels is copied into memory. Correct me if I'm wrong.

    [2] use 'DAQmx configure logging.vi', but only with the "journal" operation to write the data to a PDM file. To view the selected data, I had read a number of samples of the TDMS file in the second loop (I'm currently writing the TDMS file). In this case, I have only one copy data from the selected channels (not), but there will be more HARD drive accesses necessary.

    What is the most effective and efficient solution in this case?

    Are there ways to connect and read data with high frequencies of sampling?

    Thank you for your help.

    You say that the measurement time is 10 minutes. If you have 40 channels and you enjoy all CHs at 100 kHz, it is quite a number of values.

    In this case, I always try to approach under the conditions of use. If a measure is only 10 minutes, I just connect all PDM data and create a graphic module that could be in the same loop of consumers where connect you the data. You can always work on the raw data files big offline afterwards, the extraction of all the information you need (have a look at the product called NI DIAdem: http://www.ni.com/diadem/)

    The main issue is that the user needs to see in the graph (or perhaps a chart can be useful too). Lets say that the graph is 1024 pixels wide. It makes no sense to show multiple data to 1024 points, Yes? Every second will produce you 100 data points k per channel. What is the useful information, which should see your username? It depends on the application. In similar cases, I usually use some kind of data reduction method: I use a moving average (Point by point Mean.VI for example) with a size of the interval of 100. This way you get 100 data points of 1000 per channel every second. If you feed your graph every second with these average values, it will be able to data points in 1024 of the store (as a default) by channel (curve), which is a little more than 10 minutes, so that the user will see the entire measurement.

    So it depends on the frequency at which you send data to the consumer. For example, collect you values 1024 by iteration of the producer and send it to the consumer. Here you can make a normal means calc or a bearing (according to your needs) and he draw a graphic. This way your chart will display only the values of the last 10 seconds...

    Once I programmed some kind of module where I use a chart and not a graph, and the user can specify the interval of the absolute timestamp that is traced. If the data size is larger than the size of the chart in pixels, the module performs an average calculation in order to reduce the number of data points. Of course, if you need to see the raw data, you can specify an interval that is small. It all depends on how you program zoom functions, etc... In my case I hade a rate of 1 Hz, so I just kept all data in RAM limiting the berries to keep 24 hours of data, so that technicians could monitor the system. In your case, given the enormous amount of data, only a file read/write approach can work, if you really need access to all of the RAW data on the fly. But I hope that the values of working capital means will be enough?

Maybe you are looking for