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

Tags: Database

Similar Questions

  • SSRS for lack of outer join with the Oracle data source

    It seems to be a problem with the Oracle driver used in the Reporting SERVICES query designer.

    When you use an Oracle data source, if I create an outer join in the graphic designer, it automatically inserts '{OJ' before the join and '} ' after her.  This is an incorrect syntax for Oracle and refuses to start.  The curly braces and the JO editable in designer text, but if I go back to the graphic designer and immediately to reintegrate them.

    Only, this has started to happen a year or two ago - before that it worked, but with the old (+) syntax.

    Can it not be healed?  It makes things very difficult.

    -Geoff

    Hi Geoff,

    Thanks for posting in the Microsoft Community.

    However, the question you posted would be better suited in the Forums of the Oracle Support; We recommend that you post your query in Oracle Support Forums to get help:

    https://forums.Oracle.com/forums/main.jspa;JSESSIONID=8d92100c30d8fb401bcbd10b46c38c9ddf1a3242549a.e34SbxmSbNyKai0Lc3mPbhmSc3aNe0? CategoryID = 84

    If you have any other questions or you need Windows guru, do not hesitate to post your questions and we will be happy to help you.

  • using outer joins if the two column is null? Use only (+)

    Hi all

    create the table xxc_tr_num (tl_number number, tr_no number tl_no_id);

    insert into xxc_tr_num values (123,100,222);

    insert into xxc_tr_num values (124,100,333);

    create the table xxc_od_tab (tl_number number, tl_id number);

    insert into xxc_od_tab values (123,001);

    insert into xxc_od_tab values (null, null);

    create table xxc_oth_tab (name varchar2 (10), number of tl_id);

    insert into xxc_oth_tab values('abc',,001);

    insert into xxc_oth_tab values (null, null);

    Wait it out put

    tr_no tl_no_id name

    100 222 abc

    100 333

    using outer joins if the two column is null? use only please of outer joins

    And I tried to use outer joins on both tl_id column but not get values and I use have County (tr_no ) > 1

    Rajesh123 wrote:

    Thank you Kiss it is not possible to use having clause?

    You need to understand the functioning of the group. If you will not be asked this question.

    Check this box

    SQL> select tr_no,
      2         tl_no_id,
      3         count(*)
      4    from xxc_tr_num a,
      5         xxc_od_tab b,
      6         xxc_oth_tab c
      7   where a.tl_number = b.tl_number(+)
      8     and b.tl_id = c.tl_id(+)
      9   group
     10      by tr_no
     11       , tl_no_id;
    
         TR_NO   TL_NO_ID   COUNT(*)
    ---------- ---------- ----------
           100        333          1
           100        222          1
    

    See what returns the count? You have grouped according to TR_NO and TL_NO_ID. You must take into consideration the TL_NO_ID just put COUNT (TR_NO) does not increase the NUMBER of the whole group. To get the NUMBER on the whole group, I used the analytical function and did. Like this, see the number of the analytical function here

    SQL> select tr_no,
      2         tl_no_id,
      3         count(*),
      4         count(*) over(partition by tr_no)
      5    from xxc_tr_num a,
      6         xxc_od_tab b,
      7         xxc_oth_tab c
      8   where a.tl_number = b.tl_number(+)
      9     and b.tl_id = c.tl_id(+)
     10   group
     11      by tr_no
     12       , tl_no_id;
    
         TR_NO   TL_NO_ID   COUNT(*) COUNT(*)OVER(PARTITIONBYTR_NO)
    ---------- ---------- ---------- ------------------------------
           100        222          1                              2
           100        333          1                              2
    

    So to answer your question, yes you can't do in the HAVING clause...

  • Outer join on the Filter Condition

    Hello

    I would like to show all rows in a query for two conditions to filter on the 'status '. I used an outer join on the outer query to return the values inside the inline query, but it returns not to return all rows.

    create table (test)
    ID number,
    start_date date,
    status varchar2 (1).
    number of amount,
    number of cust_type
    );


    Insert test values (001, June 1, 2014 ", am ', 189, 78");
    Insert test values (001, March 26, 2014 ", 'R', 175, 4");
    Insert test values (001, December 1, 2014 ", 'R', 89, 91");
    Insert test values ("001, 13 August 2014 ', 'J', 19, 2);
    Insert test values (001, 12 August 2014 ', 'E', 19, 2);

    Insert test values (002, January 1, 2014 ', 'R', 17, 4);
    Insert test values (002, 26 June 2014 ", 'R', 175, 4");
    Insert test values (' 002, February 1, 2014 ', 'J', 9, 8);
    Insert test values (002, 13 October 2014 ', ', 190, 2);

    Insert test values (' 003, June 1, 2014 ', 'J', 189, 78);
    Insert test values (003, March 26, 2014 ", 'R', 175, 4");
    Insert test values (003, December 1, 2014 ", 'R', 89, 91");
    Insert test values (' 003, 13 August 2014 ', 'J', 19, 2);
    Insert test values (' 003, 12 August 2014 ', 'J', 19, 2);

    commit;

    Select i.ids, i.start_date, i.cust_type, i.amount as gross_amount, i.amount + ii.amount as net_amount
    test I have,
    (select id, amount)
    of the test
    where (status = status or 'R' = 'J')) ii
    where i.cust_type in (4, 78, 91, 2, 4, 8)
    and i.ids (+) = ii.ids
    and i.status (+) to (', 'E')
    "and i.start_date between 1 January 14 ' and 31-dec-2014."

    The query above exclude ID 003 because there is that no status (M / E) butI want always display all codes, even if the condition is not consistent

    Hello

    Want results from an inner join to match identifiers, but the results of an outer join for identifiers that are not?  In other words, you want to include the rows of the table I only when one of the following is true:

    The line of table I have ticked all the boxes, or

    No line in not table i with the same ID meets all conditions

    ?

    If so, here's a way to do it:

    WITH got_rnk AS

    (

    Select i.ids, i.start_date, i.cust_type

    , nvl2 (ii.ids, i.amount, 0) as gross_amount

    , i.amount + nvl (ii.amount, 0) as net_amount

    dense_rank () over (partition of i.ids

    order of nvl2 (ii.ids, 'A', 'B')

    ) as rnk

    I have test

    (in left outer join

    SELECT ID, amount

    of the test

    where status ('R', 'J')

    ) ii on i.ids = ii.ids

    and i.cust_type in (4, 78, 91, 2, 4, 8)

    and i.start_date between to_date (January 1, 2014 ", 'dd-mon-yyyy')

    and to_date (31-dec-2014', 'dd-mon-yyyy')

    and i.status in (', 'E')

    )

    SELECT ID, start_date, cust_type

    gross_amount, net_amount

    of got_rnk

    where rnk = 1

    ;

    Results of your sample data:

    ID START_DATE GROSS_AMOUNT NET_AMOUNT CUST_TYPE

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

    1 1 June 2014 78 189 364

    1 1 June 2014 78 189 278

    1 1 June 2014 78 189 208

    1 12 August 2014 2 19 38

    1 12 August 2014 2 19 108

    1 12 August 2014 2 19 194

    2 13 October 2014 2 190 207

    2 13 October 2014 2 190 365

    2 13 October 2014 2 190 199

    3 March 26, 2014 4 0 175

    3 1 June 2014 78 0 189

    3 12 August 2014 2 0 19

    3 August 13, 2014 2 0 19

    3 1 December 2014 91 0 89

  • outer join in the view criteria

    Hello world

    I use jdeveloper 11.1.1.6.0

    I want to create outer join in the view criteria, so I had to substitute getCriteriaItemClause ViewObjImpl.java method

    my query is like this:

    SELECT t1. row_no, t2.type FROM table_1 t1, t2 from table_2

    WHERE t1. row_no (+) = t2. row_no

    and t1.user_Id (+) =: bindVar

    table_1 (row_no, user_Id)

    table_2 (row_no, type)

    the part " t1.user_Id (+) =: bindVar " should be put in the display criteria

    the method:

    @Override

    public String getCriteriaItemClause (ViewCriteriaItem viewCriteriaItem) {}

    String newQeury = this.getEntityDef (0) .getAliasName () + "." + viewCriteriaItem.getColumnName () + "(+) =:bindVar .

    Return newQeury;

    }

    but when I run the criteria see exception below raises:

    oracle.jbo.expr.JISyntaxError: Houston-36000: an unexpected token expression is found.

    When I remove the sign "(+)" of newQeury

    String newQeury = this.getEntityDef (0) .getAliasName () + "." + viewCriteriaItem.getColumnName () + "=:bindVar .  remove the sign "(+)" before =:bindVar

    raises the exception below

    Houston-29000: Unexpected exception caught: oracle.jbo.expr.JIEvalException, msg = Houston-25077: t1 name not found in the given object: ViewRow [[5-1-5] oracle.jbo.Key].

    Habib

    This is a duplicate of https://forums.oracle.com/thread/2577092

    Please do not post your questions several times.

    A possible solution posted to the original thread.

    Timo

  • How to sort members in the Query Designer XL?

    Hello

    I want to get my product dimension members listed alphabetically Level0.

    I am able to select Level0 but do not sort.

    How can I do that with the query designer please?

    Thank you

    If you try to run it from excel, you can look at my blog http://glennschwartzbergs-essbase-blog.blogspot.com/2008_05_01_archive.html. He talks about how to run scripts from excel report

  • outer join on the aggregate query

    This is probably a relatively simple matter, as long as I explain it well enough:

    I have two tables:

    categorycodes and properties

    categorycodes is a lookup table.

    both tables have a catcode field which is a char (1) that contains matching data (only the numbers 1 to 6)

    CREATE

    TABLE CATEGORYCODES

    (

    CATCODE CHAR (1 BYTE) NOT NULL,

    DESCRIPTION VARCHAR2 (25 BYTE) NOT NULL,

    CONSTRAINT CATEGORYCODES_PK PRIMARY KEY (CATCODE) ALLOW

    )

    catCode

    1

    2

    3

    4

    5

    6

    The properties table has approximately 600 000 records. The properties table also has a field named parcelno which is a tank (9).  It contains a string of figures and numbers only.

    What I would like is:

    catCode, count (*)

    1 580

    2 300

    3 3000

    4 235

    5 0

    6 80

    I limited the results of the query to make sure it was a game that would not all catcodes in it.  I have trouble to get the one with zero to display.  I know that this has to do with how I do the join, but I don't know what.

    It is a sample of what I've tried:

    Select i.

    Of

    (select catcode, count (*)

    property p

    where substr (parcelno, 1, 3) = ' 871 "

    Catcode group) i

    outer join right categorycodes cc

    We i.catcode = cc.catcode;

    I'm not worried about the situations where catcode is null in the properties.  Parcelno cannot be null.

    Hello

    Looks like your query should work; except that you won't COUNT (*); That would make each issue at least 1.  COUNT (*) means that count the total number of lines, no matter what is on them, so he'll see the line with just the catcode of the lookup table that matches nothing and which count as 1.  You want to count the number of rows in the table of properties, so expect a column of the properties that cannot be NULL.

    Here is a slightly different way

    SELECT c.catcode

    EARL of (p.catcode) AS cnt

    OF categorycodes c

    P ON p.catcode = c.catcode LEFT OUTER JOIN properties

    AND SUBSTR (p.parcelno

    1

    3

    ) = ' 871 "

    ;

    If the condition about 871' ' part of the join condition, then you don't need a subquery.

    .

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Point where the above statement is erroneous results, and explain, using specific examples, how you get the right result of data provided in these places.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • outer join on the left, needs improvement

    Two table t1 and t2 where t1.col1 = t2.col2
    create table t1 ( col1 varchar2(20));
    insert into t1 values('aa');
    insert into t1 values('bb');
    insert into t1 values('cc');
    insert into t1 values('dd');
    insert into t1 values('ee');
    
    
    create table t2 ( col2 varchar2(20) , col3 varchar2(20));
    insert into t2 values('aa','q_aa');
    insert into t2 values('bb',' ');
    insert into t2 values('cc','q_cc');
    insert into t2 values('dd',' ');
    
    
    here is my join query:-
    select t1.col1,t2.col2,t2.col3,
    case when t2.col3 is not null then t2.col3
         when t2.col3 is null then t1.col1 end as name1                                   
    from t1 left outer join t2
    on t1.col1 =t2.col2
    real to come result
    COL1 ^ ^ COL2 ^ ^ COL3 ^ ^ NAME1
    AA ^ ^ ^ aa ^ ^ ^ q_aa ^ ^ ^ q_aa
    BB ^ ^ ^ bb
    CC ^ ^ ^ cc ^ ^ ^ q_cc ^ ^ ^ q_cc
    JJ ^ ^ ^ JJ
    ee^^^^^^^^^^^^^^^^ee

    requirement of result
    COL1 ^ ^ COL2 ^ ^ COL3 ^ ^ ^ NAME1
    AA ^ ^ ^ aa ^ ^ ^ q_aa ^ ^ ^ q_aa
    BB ^ ^ ^ bb ^ ^ ^ bb
    CC ^ ^ ^ cc ^ ^ ^ q_cc ^ ^ ^ q_cc
    JJ ^ ^ ^ DD ^ ^ ^ JJ
    ee^^^^^^^^^^^^^^^^^ ee


    and how can copy paste the result of sql * more... box when I copy paste here it automatically omit the space, as above

    The problem is values col3 to the 'bb' and 'dd' lines are not null, because they have a space in them. You can either remove the space and use:

    nvl(t2.col3,t1.col1) as name1
    

    or tim space out:

    nvl(trim(t2.col3),t1.col1) as name1
    
  • 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')
    
  • Outer joins to the left... Please help!

    Hmm. Ive had trouble with this one for a while and have read and re-read docs etc.

    IM under 11.2 XE and its Apex 4.2 application...

    Its a simple query with outer joins... but I can't simply to do it right after several hours of trying! ID be very grateful if anyone can lend a hand...

    For the query below. I am looking for the following:

    Complete list of entities, a sum of the values if they exist (and obviously empty if they don't), filtered by a table of SUM choice only the records that match a value in the lookup table.

    Select

    e.ENTITY as ENTITY,

    Sum (p.amount) as Forecast_Income,

    Sum (BR.bri_credit) as Actual_Income,

    Sum (BR.bri_debit) as Actual_Expenses

    Of

    e entities

    LEFT OUTER JOIN payments p

    WE (e.entity_id = p.entity_id)

    LEFT OUTER JOIN pmt_stat_lookup ps

    WE (p.status_id = ps.status_id

    and ps.forecast = 'Y')

    LEFT OUTER JOIN bri_recon br

    WE (e.entity_id = br.entity_id)

    E.entity group

    My problem with the join where I join p.status_id for ps.status_id and ps.forecast = 'Y '...   If I run the above statement, it seems does not account for this filter criteria and summarizes all records of PAYMENTS, regardless of...  If I move outside the outer join clause, it only brings back the records of PAYMENTS where there is a join. Ive tried to join in a different order etc... but in vain...

    If someone could help, Id be very grateful.

    Kind regards

    Richard

    Hello Richard

    Try this query:

    SELECT e.entity as ENTITY

    sum (PO.amount) as Forecast_Income

    sum (br.bri_credit) as Actual_Income

    sum (br.bri_debit) as Actual_Expenses

    Of

    E ENTITIES

    LEFT OUTER

    JOIN (SELECT P.entity_id )

    P.amount

    PAYMENTS P

    JOIN PMT_STAT_LOOKUP PS

    ON p.status_id = ps.status_id

    AND ps.forecast = 'Y '.

    ) IN.

    WE e.entity_id = in. entity_id

    LEFT OUTER

    JOIN BR BRI_RECON

    ON e.entity_id = br.entity_id

    E.entity GROUP

    ;

    I hope it helps.

    Best regards, David

    Post edited by: David Berger

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

  • How to write an outer join

    Hello
    Suppose I write an outer join like this:

    Select...
    from table_1 a, b table_2
    where a.field1 = b.field1
    and a.field2 > = b.field2

    but I know that some values may not make a match between the two tables.
    I have rewtire a query should as well?

    Select...
    from table_1 a, b table_2
    where a.field1 * (+) = * b.field1
    and a.field2 * (+) > = * b.field2

    I mean, if I put the (+) sign in the two matches?

    Thank you!

    (+) must be with this column of the table for which you want to show only the matching lines... Other tables, all rows will be displayed.

    I mean, if I put the (+) sign in the two matches?

    And Yes, it should be placed at both locations...

    AJ

  • How not to display variable binding in the query ADF search panel?

    Hello, I use JDeveloper 11.1.2.3.0.

    I have a variable binding in my VO, (* required) that I use in the sql query. I put the value of this variable to link through the groovy expression so I don't have to manually put through my page. It works fine but the problem is that it appears in the query ADF Panel that I created in my page. To do this, I created a ViewCriteria and I've specified to display only 3 (other) fields for the simple search. Apart from the selected 3 variable bind shows here again because its value is set. I tried to remove the ' * required ' of the variable binding in the original Version, but in this case I have problems with my sql query.

    Does anyone know how this variable is not to display in the Panel request ADF?

    Thank you

    Has tried to define the binding to bee hidden variable?

    Controll tips, hint of display = hide

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

  • 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

Maybe you are looking for