Outer join on aggregate query

This is probably a relatively easy question as long as I explain it well enough:
I have two tables:
categorycodes and properties
categorycodes is a lookup table.
both tables have a field catcode that is a char(1) that contains matching data (only numbers 1 - 6)
CREATE
  TABLE CATEGORYCODES
    CATCODE     CHAR(1 BYTE) NOT NULL ,
    DESCRIPTION VARCHAR2(25 BYTE) NOT NULL ,
    CONSTRAINT CATEGORYCODES_PK PRIMARY KEY ( CATCODE ) ENABLE
catcode
1
2
3
4
5
6
The properties table has about 600,000 records. The properties table also has a field called parcelno which is a char(9).  It contains a string of numbers and only numbers.
What I'd like is the following:
catcode, count(*)
1   580
2  300
3 3000
4 235
5 0
6 80
I limited the query results to make sure that there was a set that would not have all the catcodes in it.  I am having trouble getting the one with zero to display.  I know this has to do with how I'm doing the join, but I'm not sure what.
This is a sample of what I've tried:
select i.*
from
(select catcode, count(*)
from properties p
where substr(parcelno,1,3) = '871'
group by catcode) i
right outer join categorycodes cc
on i.catcode = cc.catcode;
I am not worried about situations where catcode is null in properties.  Parcelno can never be null.

Hi,
It looks like your query should work; except you don't want to COUNT (*); that would make every number at least 1.  COUNT (*) means count the total number of rows, no matter what is on them, so it will see the row with just the catcode from the lookup table that doesn't match anything, and count that as 1.  You want to count the number of rows from the properties table, so count some column from the properties that can't be NULL.
Here's a slightly different way
SELECT    c.catcode
,         COUNT (p.catcode)     AS cnt
FROM             categorycodes  c
LEFT OUTER JOIN  properties     p  ON   p.catcode   = c.catcode
                                   AND  SUBSTR ( p.parcelno
                                               , 1
                                               , 3
                                               )    = '871'
If the condition about '871' is part of the join condition, then you don't need a sub-query.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Point out where the statement above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002

Similar Messages

  • Restriction to Left Outer Joins in PS Query

    Hello I am trying to do Left Outer JOin in PS QUERY. I need to do dept tbl, job code tbl and locatable as left outer joins with JOB Table. Looks like in PS QUERY there is a error message saying as below. Can someone has any workaround to achieve this in PS QUERY. I know I can create a View and use that in PS QUERY but BUsiness Users are dependent on IT, so that doesn't work. Also, adding JOB table multiple times works but I am looking for better solution if anyone had come accorss working through PS QUERY Outer JOins.
    Windows Internet Explorer
    Left outer joins must be joined to the last record in the query. (139,290)
    OK
    Thanks,
    SC.

    Hi Mike,
    According to your description, you want to improve the performance for your DAX query in SQL Server Analysis Service Tabular model, right? Here is a white paper describes strategies and specific techniques for getting the best performance from your tabular
    models, including processing and partitioning strategies, DAX query tuning, and server tuning for specific workloads.
    http://msdn.microsoft.com/en-us/library/dn393915.aspx
    Since this is a complex DAX query, from a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with Microsoft. Visit this link to see the various
    support options that are available to better meet your needs:
    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to make outer join in Sub Query?

    Hi!
    I'm facing one problem. Can anyone tell me - how to make outer join in sub query?
    I'm pasting one sample code -
    select e.empno, e.ename,e.job,e.sal,d.deptno,d.dname
    from d_emp e, d_dept d
    where e.deptno(+) = (
                          case
                            when d_dept.deptno = 10
                              then
                                  select deptno
                                  from d_dept
                                  where dname = 'SALES'
                          else
                            d_dept.deptno
                          end
    SQL>
    ERROR at line 15:
    ORA-01799: a column may not be outer-joined to a subqueryHow to resolve this issue?
    Regards.

    And any luck with this?
    SQL> with emp as
      2  (select 100 empno, 'Abcd' ename, 1000 sal, 10 deptno from dual
      3  union all
      4  select 101 empno, 'RRR' ename, 2000 sal, 20 deptno from dual
      5  union all
      6  select 102 empno, 'KKK' ename, 3000 sal, 30 deptno from dual
      7  union all
      8  select 103 empno, 'PPP' ename, 4000 sal, 10 deptno from dual
      9  )
    10  ,dept as
    11  (select 10 deptno, 'FINANCE' dname from dual
    12  union all
    13  select 20 deptno, 'SALES' dname from dual
    14  union all
    15  select 30 deptno, 'IT' dname from dual
    16  union all
    17  select 40 deptno, 'HR' dname from dual
    18  )
    19  select e.empno, e.ename, e.sal, d.deptno, d.dname
    20  from emp e,
    21       (select decode(a.deptno, 10, b.deptno, a.deptno) deptno, decode(a.deptno, 10, b.dname, a.dname) dname
    22      from dept a, (select deptno, dname
    23                    from dept
    24                      where dname = 'SALES'
    25                     ) b
    26       ) d
    27  where e.deptno(+) = d.deptno
    28  /
         EMPNO ENAM        SAL     DEPTNO DNAME
           101 RRR        2000         20 SALES
           101 RRR        2000         20 SALES
           102 KKK        3000         30 IT
                                       40 HR
    SQL> Cheers
    Sarma.

  • Outer Join with the query

    I have written the below query, our requirement is, Some employees have "Transport Allowance" but not "Project Allowance". For this, I tried to use OUTER JOIN with this query. But this query takes long time and failed. The following query works fine if the employee has both "Transport Allowance" and "Project Allowance" (without outer join) Now, I also need to retrieve the employees who have "Transport Allowance" but not "Project Allowance". How can I retrieve it?
    SELECT DISTINCT papf.employee_number
    , peev.screen_entry_value Transport_Allowance
    ,peev1.screen_entry_value Project_Allowance
    FROM apps.per_all_people_f papf
    ,apps.per_all_assignments_f paaf
    ,apps.pay_element_types_x petf
    ,apps.pay_element_types_x petf1
    ,apps.pay_element_types_x petf2
    ,apps.pay_element_entries_f peef
    ,apps.pay_element_entries_f peef1
    ,apps.pay_element_entries_f peef2
    ,apps.pay_element_entry_values_x peev
    ,apps.pay_element_entry_values_x peev1
    ,apps.pay_element_entry_values_x peev2
    ,apps.pay_input_values_x pivf
    ,apps.pay_input_values_x pivf1
    ,apps.pay_input_values_x pivf2
    WHERE
    papf.person_id = paaf.person_id
    AND paaf.assignment_id = peef.assignment_id
    AND paaf.assignment_id = peef1.assignment_id
    AND paaf.business_group_id = papf.business_group_id
    --Transport Allowance
    AND peef.element_entry_id = peev.element_entry_id
    AND petf.element_Name = 'Transport Allowance'
    AND pivf.element_type_id =petf.element_type_id
    AND pivf.name = 'Allowance'
    AND peev.input_value_id= pivf.input_value_id
    --Project Allowance
    AND peef1.element_entry_id = peev1.element_entry_id
    AND petf1.element_Name = "Project Allowance'
    AND pivf1.element_type_id = petf1.element_type_id
    AND pivf1.name = 'Allowance'
    AND peev1.input_value_id = pivf1.input_value_id
    AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
    AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
    AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
    ORDER BY papf.employee_number
    Thanks in advance.

    I am using sames tables with alias to retrieve the columns values from the same table.
    Here is my query.
    SELECT DISTINCT papf.employee_number
    , peev.screen_entry_value Transport_Allowance
    ,peev1.screen_entry_value Project_Allowance
    FROM apps.per_all_people_f papf
    ,apps.per_all_assignments_f paaf
    ,apps.pay_element_types_x petf
    ,apps.pay_element_types_x petf1
    ,apps.pay_element_entries_f peef
    ,apps.pay_element_entries_f peef1
    ,apps.pay_element_entry_values_x peev
    ,apps.pay_element_entry_values_x peev1
    ,apps.pay_input_values_x pivf
    ,apps.pay_input_values_x pivf1
    WHERE
    papf.person_id = paaf.person_id
    AND paaf.assignment_id = peef.assignment_id
    AND paaf.assignment_id = peef1.assignment_id
    AND paaf.business_group_id = papf.business_group_id
    --Transport Allowance
    AND peef.element_entry_id = peev.element_entry_id
    AND petf.element_Name = 'Transport Allowance'
    AND pivf.element_type_id =petf.element_type_id
    AND pivf.name = 'Allowance'
    AND peev.input_value_id= pivf.input_value_id
    --Project Allowance
    AND peef1.element_entry_id = peev1.element_entry_id
    AND petf1.element_Name = "Project Allowance'
    AND pivf1.element_type_id = petf1.element_type_id
    AND pivf1.name = 'Allowance'
    AND peev1.input_value_id = pivf1.input_value_id
    AND (SYSDATE BETWEEN peev.effective_start_date AND peev.effective_end_date)
    AND (SYSDATE BETWEEN peev1.effective_start_date AND peev1.effective_end_date)
    AND (SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date)
    ORDER BY papf.employee_number
    Thanks in advance.

  • How to use outer join on this query?

    Hi all,
    Hope doing well,
    sir i am having one query which is here
    SELECT C.* ,
    P.Comp_Name Parent
    FROM Comp_Master C
    LEFT JOIN Comp_Master P
    ON C.Parent_ID = P.Comp_ID
    WHERE C.Comp_ID = 5;
    and here is my table Comp_Master data like this:
    Comp_ID Parent_ID Comp_Name
    5 1 abc123
    1 ROOT abc@123
    after running this query with all column value in parent column abc@123 value should come. but it's not happening.
    could u check this.
    if any query please let me know.
    Thanks

    p.s. when I run your query against your data....
    SQL> ed
    Wrote file afiedt.buf
      1  with comp_master as (select '5' comp_id, '1' parent_id, 'abc123' comp_name from dual union all
      2                       select '1' comp_id, 'ROOT' parent_id, 'abc@123' comp_name from dual
      3                      )
      4  --
      5  -- end of simulated table of test data
      6  --
      7  SELECT C.*
      8        ,P.Comp_Name Parent
      9  FROM Comp_Master C
    10       LEFT JOIN Comp_Master P ON C.Parent_ID = P.Comp_ID
    11* WHERE C.Comp_ID = 5
    SQL> /
    C PARE COMP_NA PARENT
    5 1    abc123  abc@123I get the output I expect from that query.
    So what are you expecting?
    I just ran the equivalent in SQL Server (I can't believe you got me to go and run that piece of rubbish... I haven't touched it in ages)...
    with comp_master as (select '5' comp_id, '1' parent_id, 'abc123' comp_name union all
                         select '1' comp_id, 'ROOT' parent_id, 'abc@123' comp_name
    SELECT C.*
          ,P.Comp_Name Parent
    FROM Comp_Master C
         LEFT JOIN Comp_Master P ON C.Parent_ID = P.Comp_ID
    WHERE C.Comp_ID = 5... and it gave me the same output.

  • Query with FULL OUTER JOIN , help pleaseeeeeeeeeeee...

    Hi everyone,
    I'm trying to write a query for a report in Oracle SQL, but i just can't figure out how to do it.
    I'm using Oracle 10g release 1.0 database and i execute my queris in SQL* PLUS ( eventually i'm gonna use them in Oracle Report Builder ) .
    here's what i have:
    i have four tables that are used for our inventory application. lets call them INCOMMING , INCOMMING_ITEMS , OUTGOING , OUTGOING_ITEMS.
    as you may have guessed , INCOMMING_ITEMS is the detail table for INCOMMING ( joined by IID column) and also OUTGOING_ITEMS is the detail table for OUTGOING ( joined by OID column ).
    here is the structure of them :
    INCOMMING
    IID varchar2
    CDATE date
    INCOMMING_ITEM
    IID varchar2
    PART_NO number
    QTY number
    OUTGOING
    OID varchar2
    CDATE date
    OUTGOING_ITEM
    OID varchar2
    PART_NO number
    QTY number
    now , the query i want, should return part_no , cdate , sum of OUTGOING qty , sum of INCOMMING qty .
    the result of the query should be sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/06     10     0
    100     01/05/07     20     60
    200     01/06/02     0     50
    300     01/06/02     30     40
    this means that for some dates and for some parts, i may not have INCOMMING or OUTGOING data, but if at least one of the 2 last columns has a non-zero data, i should show the row ( like the first and third rows of my example result), and if both have data for the same PART_NO and the same CDATE, both should be showed in the same row. ( like the second row in my example result)
    i tried so much and came up with several huge and also time consuming queries, but then i read abt FULL OUTER JOIN somewhere and tried using that. here is what i came up with :
    SELECT
    PART_NO , CDATE , sum(II.QTY) I_QTY , SUM (OI.QTY) O_QTY
    FROM
         (OUTGOING O INNER JOIN OUTGOING_ITEM OI USING ( OID ) )
    FULL OUTER JOIN
         (INCOMMING I INNER JOIN INCOMMING_ITEM II USING ( IID ) )
    ON ( I.CDATE = O.CDATE AND II.PART_NO = OI.PART_NO)
    WHERE
    I.CDATE = :PARAMETER1
    AND O.CDATE = :PARAMETER1
    GROUP BY
    PART_NO , CDATE
    this query is short and fast , but the results r not what i expected. i mean, although i have used FULL OUTER JOIN in the query , but the results i get r sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/07     20     60
    300     01/06/02     30     40
    which means only the rows that has both values are returned.
    any change i make to this query would make the SQL* PLUS hang , like when i use the cartesian product of two large tables, so i guess my changes wheren't in the right direction.
    i think its possible to write this query using FULL OUTER JOIN syntax, but i just can't find it.
    Can anybody pleaseeeeeeeeeeeee help me?
    thanx in advance,
    Maryam.

    Note: I wrote this on the fly -- hope there is no syntax errors, otherwise forgive me -- but you get the idea..
    select
    fromUnionAll.cdate, fromUnionAll.part_no,
    sum(fromUnionAll.O_qty) O_qty,
    sum(fromUnionAll.I_qty) I_qty
    from
    select
    iinner.cdate, iinner.part_no, 0 O_qty, iinner.I_qty
    from
    select
    i.cdate, ii.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in INCOMMING_item */
    sum( ( case when ii.qty is not null then ii.qty else 0 end) ) I_qty
    from
    incomming i,
    incomming_item ii
    where
    i.iid = ii.iid (+)
    group by i.cdate, ii.part_no
    ) iinner
    union all
    select
    oinner.cdate, oinner.part_no, oinner.O_qty, 0 I_qty
    from
    select
    o.cdate, oi.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in OUTGOING_item */
    sum( ( case when oi.qty is not null then oi.qty else 0 end) ) O_qty
    from
    outgoing o,
    outgoing_item oi
    where
    o.oid = oi.oid (+)
    group by o.cdate, oi.part_no
    ) oinner
    ) fromUnionAll
    group by fromUnionAll.cdate, fromUnionAll.part_no;
    --Samson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Query with multiple outer joins

    I had a doubt with whether the following kind of query is valid with multiple outer-joins. The format of the query is something like this:-
    select A.col1, B.col2
    from table1 A, table2 B, table3 C where
    A.col3=B.col4(+) and B.col5=C.col6(+)
    This would mean the follwoing with regard to outer-joins in the query.
    1) fetch records with col3 in table A matching or not matching col4 in table B
    2) fetch records with col5 in table B matching or not matching col6 in table C
    So, this query is valid?
    I hope, my question is clear.
    Please, help in solving the doubt.
    regards

    This is valid and it works fine

  • Query Of Queries : Error When Trying To Fake Left Outer Join

    Hi there
    I am trying to replicate a left outer join, combining two query of queries using a method I located here
    However, I keep getting an error message..
    Here is the code I am using....
        <cfquery dbtype="query" name="qry">
                    SELECT *
                    FROM returnQry, returnQry2
                    WHERE returnQry.mediumImage = returnQry2.mediumImage
                    ORDER BY returnQry.name   
                </cfquery>
                <cfquery name="returnQry3" dbtype="#application.mx#">
                    SELECT *
                    FROM trackmeanings AS t
                </cfquery>      
               <cfquery dbtype="query" name="endQry">
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM qry, returnQry3
                    WHERE qry.name = returnQry3.sNameTrack
                    UNION
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM 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,  Expected one of [like|null|between|in|comparison] condition"
    Would anyone have any ideas?
    Many thanks

    Actually , spoke a little too soon, my query now seems to be outputting duplicates when the value is found on both sides of the union, my group by clause doesnt seem to be eliminating them like it usually does.
    My SELECT code now reads
    <cfquery dbtype="query" name="endQry">
    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
    FROM qry, returnQry3
    WHERE qry.name = returnQry3.sNameTrack
    GROUP BY name,nameRcd,mediumImage
    UNION
    SELECT name,nameRcd,mediumImage, 0 AS comments
    FROM qry
    WHERE qry.name NOT IN (<cfqueryparam
    value="#returnQry3.sNameTrack#"
    cfsqltype="cf_sql_varchar"
    list="yes"
    />)
    GROUP BY name,nameRcd,mediumImage
    ORDER BY name DESC
    </cfquery>
    and my ouput...is producing duplicates
    <cfoutput query="rc.qryTopTracks" group="name">
    #rc.qryTopTracks.name#
    </cfoutput>
    Would you have any idea of how to eliminate them here?  Thanks

  • Query by example and outer join supported?

    Does TopLink support outer joins when using query by example and cursored streams? I am having problems getting this to work. It seems to completely ignore the requested outer join.
    I have tried several variations of what is below, but have never seen TopLink generate the outer join. This is against Oracle 9i on TopLink 9.0.4.5.
    Customer 1->1 Address (using valueholder indirection)
    ReadAllQuery q = new ReadAllQuery();
    q.setReferenceClass(Customer.class);
    QueryByExamplePolicy policy = new QueryByExamplePolicy();
    policy.addSpecialOperation(String.class, "like");
    q.setQueryByExamplePolicy(policy);
    ExpressionBuilder builder = q.getExpressionBuilder();
    Expression addressExp = builder.getAllowingNull("address");
    q.addJoinedAttribute(addressExp);
    q.addOrdering(addressExp.get("city").ascending());
    q.useCursoredStream(end-start, end-start);
    q.setExampleObject(exampleCustomer);
    CursoredStream stream = (CursoredStream)s.executeQuery(q);
    ...iterate through the stream...
    Note, that the database level relationship is expressed through a target foreign key.
    (     addressMapping.addTargetForeignKeyFieldName("ADDRESS.CUSTOMER_ID", "CUSTOMER.CUSTOMER_ID");)
    Any help would be appreciated.
    Thanks,
    Kevin

    Kevin,
    I spoke too soon. All you need to do is use the getAllowingNull in the ordering expression and not use the addJoinedAttribute. With this you can use query-by-example with additional outer-joined ordering.
    Here is an example based on the Employee demo:
    ReadAllQuery raq = new ReadAllQuery(Employee.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    raq.addOrdering(eb.getAllowingNull("address").get("city").ascending());
    Employee exampleEmp = new Employee();
    exampleEmp.setLastName("%");
    // My default constructor populates the period so I'll null them so
    // they are not included in the selection criteria of the example object
    exampleEmp.getPeriod().setStartDate(null);
    exampleEmp.getPeriod().setEndDate(null);
    QueryByExamplePolicy policy = new QueryByExamplePolicy();
    policy.addSpecialOperation(String.class, "like");
    raq.setQueryByExamplePolicy(policy);
    raq.setExampleObject(exampleEmp);
    List emps = (List) session.executeQuery(raq);
    I hope this helps,
    Doug

  • OBIEE not applying outer join syntax to filters

    (Note: I've already thoroughly searched the forums before posting this. Thanks)
    My problem is the following:
    I'm trying to build a report that is a count from my fact table, grouped by month from my date dimension for a given year, resulting in 12 data points. The problem is that not all months have actual data, but I still need those months to show on the report with a count of zero. Typical simple reporting requirement.
    I have already done the obvious and within my business layer made the join between my fact table and my date dimension an outer join on the fact side, just like you'd do if writing the query by hand. And when tested by hand this includes all dates for the year anyway, and when coupled with the appropriate null test on the count measure I'd get my 12 data points with zeros were appropriate.
    The problem is that there are additional filters I need to apply on the fact data (there are a couple text-based code values that didn't warrant full tables themselves so are just degenerate dimensions directly on the fact table.)
    When these filters are applied at the Answer level, I'm only getting back the months that actually have data, and lose the months where the count should be zero. A check of the session log for the query that was generated shows the problem. While OBI properly generates the outer-join syntax for the join itself between the two tables (my date dim and fact table) it does NOT apply the outer-syntax to the constant-based filter against the fact, effectively negating the outer join.
    Actual query from the log (I simply changed the table aliases from the ugly T##### stuff OBI generates to something more readable for posting here):
    select D.DT_MONTH_NAME as c1,
    D.DT_MONTH_NUM as c2,
    I.INC_TYPE as c3,
    I.INC_EMP_GROUP as c4,
    sum(case when I.INC_KEY is null then 0 else 1 end ) as c5
    from DATE_DIM D, INCIDENT_F I
    where ( D.DATE_KEY = I.DATE_KEY (+) ) and ( D.DT_YEAR = 2010 and I.INC_EMP_GROUP = 'CONTRACTOR' )
    group by D.DT_MONTH_NUM, D.DT_MONTH_NAME, I.INC_TYPE, I.INC_EMP_GROUP
    order by c2
    You can see that the outer syntax (+) is applied to the join, but not to the filter on I.INC_EMP_GROUP. If I take this query and drop it in something like SQL Developer, it only returns the months with data. If I throw the (+) after I.INC_EMP_GROUP like I'd do if writing this by hand, the desired zero-months results pop back in.
    I have already searched the forums and while lots of people seem to have asked this question, the only solutions involve things like trickery in the business layer using dummy fact tables followed by manipulations at the report level etc. Unfortunately I can't rely on these as the system is eventually to be turned over to users who can't be expected to apply various hacks to write reports.
    Anyone ever get to the bottom of getting OBI to apply outer join logic in filters as well, when the filtered table is meant to be outer-joined to?
    Any comments are appreciated.
    John

    I know that this thread is a bit old thought it might be helpful to some one...
    The Issue is, when using Degener@teDimen$ion ( this is !nner joned to FACT tables in BMM) and if any of the dimensions {other than theDegener@teDimen$ion (Let us say Dim X) } have an ()uter join to any of the fact tables, and you were doing your analysis using Degener@teDimen$ion,  Dim X, Measure value you will face the following issues.
    when filtering the analysis on the ()uter join dimension ( Dim X), the IN filter will not work. Reason is that the filter is getting applied to both the Dimension and FACT tables and the values that exist in Dimension Dim X but not in FACT table wont show up.
         The above issue can be fixed by changing the join between the fact and Degener@teDimen$ion from inner to outer. I think this is a bug.. because  it is supposed to filter the fact  table after the entire outer joined result is obtained but not filter the fact table for the Dim X values and do a outer join. I think the BI should be intelligent enough.

  • How to understand the way OBIEE implements outer joins?

    Hello guys
    I have a few scenarios where I have to implement outer joins and inner joins between dimensions and facts..
    There are 2 ways as far as I know that allows me to implement outer joins in BMM layer.
    1, Join the Logical dim table A to Logical Fact table B using outer join. The modeling will look like the below:
    A Dim ---outer------B fact -----------inner----C Dim
    By this design, the query that selects columns from all 3 tables will look at this:
    select columns from ((B fact inner joins C on key1 = key2) left outer joins on A dim) on key3=key4)..
    2, Join logical dim table A to fact table B inside the LTS of fact B by mapping the LTS B to dim A using outer join. then join fact B to C:
    B fact (mapped to fact B outer join Dim A) ------------inner -------C dim
    By this design, the query that selects columns from all 3 tables will look at this instead:
    select columns from C, B left outer join A on key1=key2 where key3=key4
    Comparing these 2 queries, the first one seems to do inner joins first and then outer join the result set to Dim A, the second query seems to outer join Dim A first and the result set inner joins to Dim C..
    I ran the same report using these 2 different designs, and the data comes out very different. The report of the first query is much smaller than the report of the second query...
    Can anyone help me understand how OBIEE understands outer joins? The second query is so far giving the right result, however, I can't get rid of the outer join in the query even if not selecting columns from Dim A, which is impacting the performance of other reports without Dim A.
    Your inputs will be greatly appreciated
    Thanks
    Edited by: user7276913 on Apr 20, 2010 9:31 AM
    Edited by: user7276913 on Apr 20, 2010 9:31 AM

    Xcode is the IDE.
    Objective-C is the language typically used.
    There's lots of getting started stuff at https://developer.apple.com

  • Popup LOV fails in firefox when using an outer join!!!

    I have a popup lov which contains at least 2 outer joins in my query. The popup renders fine in IE but i get the error message:
    "Popup List of Values query is invalid, a display and a return value are needed, the column names need to be different"
    when launching the popup from Firefox (1.5.0.2)
    Anyone got any idea why this works in IE but fails in Firefox?
    Cheers
    Duncan

    Hello,
    Duncan – If you'll run your example code on SQL*Plus, you'll see that for department "OPERATIONS" there is no returned value. This could happen with outer join. The problem can be with the way FF is interpreting this non-value. I didn't try it my self, but maybe if you'll use display null value with your LOV, it will solve the problem. Another possible option is to use NVL() on the returned value.
    Chris – Some of the Apex team members, like Carl, are using FF as their main browser. There are some compatibility issues with the last version of FF, but from that, to your conclusion of Apex only support IE, there's a long road.
    Regards,
    Arie.

  • Problematic sql with outer join

    There is one sql statement:
    INSERT INTO XXOM_SSC_TEMP_MMI_GTEMP (HEADER_ID, LAST_UPDATE_DATE) SELECT DISTINCT OOH.HEADER_ID, XSOH.LAST_UPDATE_DATE FROM OE_ORDER_HEADERS_ALL OOH INNER JOIN (SELECT TRANSACTION_TYPE_ID FROM OE_TRANSACTION_TYPES_TL OTT WHERE OTT.NAME NOT IN ('ORDER_RMA_MMI' ) AND OTT.LANGUAGE = 'US') OTT ON (OTT.TRANSACTION_TYPE_ID = OOH.ORDER_TYPE_ID) LEFT OUTER JOIN XXOM_3LP_SYM_ORA_ORDER_HDR XSOH ON (TO_CHAR (XSOH.ORDERTYPE) = SUBSTR ( OOH.ORIG_SYS_DOCUMENT_REF, 1, INSTR (OOH.ORIG_SYS_DOCUMENT_REF, '-', 1) - 1) AND TO_CHAR (XSOH.ORDERNBR) = SUBSTR ( OOH.ORIG_SYS_DOCUMENT_REF, INSTR (OOH.ORIG_SYS_DOCUMENT_REF, '-', 1) + 1) AND (XSOH.LAST_UPDATE_DATE >= :B1 )) INNER JOIN OE_ORDER_LINES_ALL OOL ON (OOH.HEADER_ID = OOL.HEADER_ID AND OOL.SHIP_FROM_ORG_ID = :B2 ) WHERE OOH.BOOKED_FLAG = 'Y' AND XSOH.ORG_ID = OOH.ORG_ID
    Porblematic query has insufficient and sub-optimal join conditions which makes it more expensive.One has recommended to remove one unnecessary outer join from the query and also fix the join to pick index.
    But how can we remove outer join and in place of that what should we write.

    Your code is unreadable, man! Surely your boss does not let you produce stuff like that? Format it. Because I'm a helpful person, I just put it through the formatter on http://www.dpriver.com/pp/sqlformat.htm :INSERT INTO xxom_ssc_temp_mmi_gtemp
                (header_id,
                 last_update_date)
    SELECT DISTINCT OOH.header_id,
                    XSOH.last_update_date
    FROM   oe_order_headers_all OOH
           inner join (SELECT transaction_type_id
                       FROM   oe_transaction_types_tl OTT
                       WHERE  OTT.name NOT IN ( 'ORDER_RMA_MMI' )
                              AND OTT.LANGUAGE = 'US') OTT
                   ON ( OTT.transaction_type_id = OOH.order_type_id )
           left outer join xxom_3lp_sym_ora_order_hdr XSOH
                        ON ( To_char (XSOH.ordertype) =
                             Substr (OOH.orig_sys_document_ref,
                             1,
                             Instr (OOH.orig_sys_document_ref,
                             '-', 1)
                             - 1)
                             AND To_char (XSOH.ordernbr) =
                                 Substr (OOH.orig_sys_document_ref,
                                 Instr (OOH.orig_sys_document_ref, '-', 1) + 1
                             AND ( XSOH.last_update_date >= :B1 ) )
           inner join oe_order_lines_all OOL
                   ON ( OOH.header_id = OOL.header_id
                        AND OOL.ship_from_org_id = :B2 )
    WHERE  OOH.booked_flag = 'Y'
           AND XSOH.org_id = OOH.org_id

  • Slow outer joins

    I have a table (about 700,000 records) with a foreign key into a smaller table (about 10 records). NULL's are used for missing data in the large table on the foreign key field. If I do an inner join between these tables, the response is very fast, but if I use an outer join (to include the rows with NULL's) the response becomes very slow.
    Am I missing something here? I've come across to Oracle from SQL Server, and the difference in performance wasn't evident there.

    You may want to consider replacing outer joins with scalar query if possible.
    SELECT C1, C2,
                  (SELECT C3 FROM T2 WHERE T1.C1 = T2.C1)
      FROM T1;

  • Equi join as well as outer join

    Hi all,
    I have two table. They have common fields case_id and issuer_id.
    I want to retrieve the data from two tables first based on case_id(equi join) and then issuer_id(outer join). The query like this
    select t1.case_id,t1.case_name,t2.issuer_name from case t1,issuers t2
    where t1.case_id=t2.case_id and t1.issuer_id=t2.issuer_id(+)
    The above query displays error
    so, My query first gets the data based on equijoin , then i want to apply outer join on that same tables.
    plz try to solve the above problem

    SQL> create table mycase
      2  as
      3  select 1 case_id, 'NAME1' case_name, 1 issuer_id from dual union all
      4  select 2, 'NAME2', 2 from dual union all
      5  select 3, 'NAME3', 3 from dual union all
      6  select 4, 'NAME3', 4 from dual
      7  /
    Tabel is aangemaakt.
    SQL> create table issuers
      2  as
      3  select 1 case_id, 1 issuer_id, 'ISSUER1' issuer_name from dual union all
      4  select 2, 3, 'ISSUER2' from dual union all
      5  select 3, 4, 'ISSUER3' from dual union all
      6  select 4, 6, 'ISSUER4' from dual
      7  /
    Tabel is aangemaakt.
    SQL> select t1.case_id,t1.case_name,t2.issuer_name from mycase t1,issuers t2
      2  where t1.case_id=t2.case_id and t1.issuer_id=t2.issuer_id(+)
      3  /
                                   CASE_ID CASE_ ISSUER_
                                         1 NAME1 ISSUER1
    1 rij is geselecteerd.The above query doesn't make sense: the outer join predicate says "if I don't find a matching issuer_id, Oracle please make up an entire null issuer record for this one". Then the other predicate says "t1.case_id=t2.case_id" where a null value for t2.case_id will never match t1.case_id and will be excluded from the result set. Effectively you could drop the plus sign in this query to achieve the same result.
    Maybe you want the query below?
    SQL> select t1.case_id
      2       , t1.case_name
      3       , case t1.issuer_id
      4         when t2.issuer_id then t2.issuer_name
      5         else null
      6         end issuer_name
      7    from mycase t1
      8       , issuers t2
      9   where t1.case_id = t2.case_id
    10  /
                                   CASE_ID CASE_ ISSUER_
                                         1 NAME1 ISSUER1
                                         2 NAME2
                                         3 NAME3
                                         4 NAME3
    4 rijen zijn geselecteerd.Regards,
    Rob.

Maybe you are looking for

  • Burned cd's won't work

    I burned two CD's on my roomate's computer (not the same video on both) with a couple of AVI movies that, while on my hard drive, worked just fine. I burned the CD and it mounted on my system fine, but VLC couldn't read it. It's not VLC's problem bec

  • Condition Pricing Date is Diff. from PO Creation date

    Hi, We have created a PO 1100041212 on dtd. 05.05.2011. In PO Conditions tab, i have a field in the detail view ' Condition Pricing Date'. For Condition type P001, it is not showing the PO date. (mostly cases has the same date of PO Creation date) Co

  • How to Implement N-Level Approval for Bid,Live Auction,PO,Contract ?

    Hi Experts,               I am new to SRM 5.0. My requirement is how to implement N-Level Approval for Bid, Auction, PO and Contract? Which steps should I follow for        N-Level Approval? Can any one send me sample code and name of BADI where I ha

  • ORA-01031 insuffiecient privilidges

    i am unable to login to oracle 10g as 'sys' as sysdba it is throwing an error like ORA-01031 insufficient privilidges for sys. but when i connect to database with username=system and password = oracle i am able to connect to database. i have installe

  • Working android apps now crash after Mountain Lion upgrade

    I've developed two air for android apps that are on the market using Adobe Air/ Flash Builder.. I just purchased a new mac laptop with Mountain Lion which is a big upgrade over my old machine. The problem is, when I loaded my old project folders into