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.

Similar Messages

  • Defaulting Null Values in an outer join to the last joined row's values.

    I have a situation where I need to fill in the missing values from an outer join with the last values returned by the join.
    The query is based on a date table, an organization table and a transaction table.
    SELECT D.DATE_ID, O.ORG_ID, T.VALUE
    FROM D_ORGANIZATION O, D_DATE D, F_TRANSACTION T
    WHERE D.DATE_ID = T.DATE_ID(+)
    AND T.ORG_ID = O.ORG_ID(+)
    AND O.ORG_NAME = '&NAME'[
    AND D.THE_DATE >= ADD_MONTHS( TO_DATE( '&&PERIOD_DATE', 'DD-MON-YYYY' ), -23 )
    AND D.THE_DATE <= ADD_MONTHS( TO_DATE( '&&PERIOD_DATE', 'DD-MON-YYYY' ), 24 )
    So the query will return all dates in the 4 year period, and where transactions exist the relevent value.
    DATE_ID ORG_ID VALUE
    38291     2 99.8
    38321     2 45.1
    38352     
    38383     
    38411     
    What I need to happen is:
    DATE_ID ORG_ID VALUE
    38291     2 99.8
    38321     2 45.1
    38352     2 45.1     
    38383 2 45.1
    38411     2 45.1
    Lag appears to be of no use because it will only pick up the last genuine value, so using
    NVL(T.VALUE, LAG(T.VALUE,1) OVER ( .... )
    Gives:
    ATE_ID ORG_ID VALUE
    38291     2 99.8
    38321     2 45.1
    38352     2 45.1     
    38383
    38411     
    The length of the data gap can vary as constituent organisations don't all return their data at the same time, and there may be intermediate dates where no data is returned , but the value needs to be calculated.
    What's going on here is that a gaph is being generated where the tool requires data points to plot the line, once the real data ends a bespoke trend calculations takes over based on the last value returned. I do not have access to the data warehousing options so a solution that doen't need them would be handy, but if not then options can be purchased.
    The tool can't use PL/SQL, but is perhaps a bespoke function in order?

    To do this wouldn't you need to know the data in advance? The real source table had 1800 organisations and 8,000,000 transactions.
    I Tried this as well, creating a pl/sql package as follows.
    create or replace PACKAGE stack AS
    TYPE gnt_push_numbers IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
    TYPE gvt_push_varchars IS TABLE OF VARCHAR(1000) INDEX BY PLS_INTEGER;
    gna_push_numbers gnt_push_numbers;
    gva_push_varchars gvt_push_varchars;
    FUNCTION PUSH ( pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
    FUNCTION PUSH ( pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
    FUNCTION POP_NUM ( pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
    FUNCTION POP_VAR ( pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
    END stack;
    CREATE OR REPLACE
    PACKAGE BODY "STACK" AS
    FUNCTION push(pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER deterministic IS
    BEGIN
    gna_push_numbers(pn_offset) := pn_push_var;
    RETURN pn_push_var;
    END push;
    FUNCTION push(pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR deterministic IS
    BEGIN
    gva_push_varchars(pn_offset) := pv_push_var;
    RETURN pv_push_var;
    END push;
    FUNCTION pop_num(pn_offset NUMBER) RETURN NUMBER deterministic IS
    BEGIN
    RETURN gna_push_numbers(pn_offset);
    END pop_num;
    FUNCTION pop_var(pn_offset NUMBER) RETURN VARCHAR deterministic IS
    BEGIN
    RETURN gva_push_varchars(pn_offset);
    END pop_var;
    END stack;
    Unfortunately it appears to act before the rows are sorted, so will only work in specialised circumstances, in that you have to ensure the rows have been sorted before the function is used.
    SELECT PUSH(COL), POP..(COL)
    FROM ( SELECT etc.
    Luckily the client decided they didn't want to mix their graphs any more so a more classic approach using a base table select for actuals and then a date table select with a sub-query columns for the projection provided a simple solution.

  • Maximum number of tables that can be outer joined with one table in a query

    Hi All,
    Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
    Thanks,
    Srini

    srinu2 wrote:
    Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
    There is no limit to the number of tables you can outer join as long as you join them correctly.
    SQL> with a as
      2      (
      3      select 1 id, 2 b_key, 3 c_key from dual union all
      4      select 2 id, 1 b_key, 4 c_key from dual union all
      5      select 3 id, 3 b_key, 1 c_key from dual union all
      6      select 4 id, 4 b_key, 2 c_key from dual
      7      ),
      8      b as
      9      (
    10      select 1 id, 1 c_key2 from dual union all
    11      select 2 id, 5 c_key2 from dual union all
    12      select 3 id, 3 c_key2 from dual union all
    13      select 4 id, 2 c_key2 from dual
    14      ),
    15      c as
    16      (
    17      select 1 key1, 1 key2, '1-1' dta from dual union all
    18      select 1 key1, 2 key2, '1-2' dta from dual union all
    19      select 1 key1, 3 key2, '1-3' dta from dual union all
    20      select 1 key1, 4 key2, '1-4' dta from dual union all
    21      select 2 key1, 1 key2, '2-1' dta from dual union all
    22      select 2 key1, 2 key2, '2-2' dta from dual union all
    23      select 2 key1, 3 key2, '2-3' dta from dual union all
    24      select 2 key1, 4 key2, '2-4' dta from dual union all
    25      select 3 key1, 1 key2, '3-1' dta from dual union all
    26      select 3 key1, 2 key2, '3-2' dta from dual union all
    27      select 3 key1, 3 key2, '3-3' dta from dual union all
    28      select 3 key1, 4 key2, '3-4' dta from dual union all
    29      select 4 key1, 1 key2, '4-1' dta from dual union all
    30      select 4 key1, 2 key2, '4-2' dta from dual union all
    31      select 4 key1, 3 key2, '4-3' dta from dual union all
    32      select 4 key1, 4 key2, '4-4' dta from dual
    33      )
    34  select d.a_id, d.b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
    35  from
    36      c,
    37      (
    38      select
    39          a.id as a_id, b.id as b_id, a.c_key, b.c_key2
    40      from a, b
    41      where a.b_key = b.id
    42      ) d
    43  where d.c_key = c.key1 (+)
    44  and   d.c_key2 = c.key2 (+);
          A_ID       B_ID     C_KEY1     C_KEY3 DTA
             3          3          1          3 1-3
             4          4          2          2 2-2
             2          1          4          1 4-1
             1          2
    SQL>

  • Outer join with effective date in peoplesoft query

    Hi,
    I'm trying to join two tables using outer join. Both tables are effective dated:
    Dept_Tbl: dept_id, status, effdt
    Tips_Tbl: dept_id, tips_id, effdt
    Not all records in Dept_Tbl are in Tips_Tbl. I need to get all active depts and their most recent tips_id if they have one.
    select a.dept_id, b.tips_id
    from dept_tbl a, tips_tbl b
    where a.status = 'Active'
    and a.effdt =
    (select max(a_ed.effdt) from dept_tbl a_ed
    where a.dept_id = a_ed.dept_id
    and a_ed.effdt <= SYSDATE)
    and b.dept_id(+) = a.dept_id
    and b.effdt =
    (select max(b_ed.effdt) from tips_tbl b_ed
    where b.dept_id = b_ed.dept_id
    and b.tips_id = b_ed.tips_id
    and b_ed.effdt <= SYSDATE)
    The query only returns records that are in both tables.
    Is there a way for outer join to work with effective dates?
    Thanks in advance,
    Reg

    Here is an example of one solution. Note the use of NVL on both sides of the equal sign since both sides could be NULL in the case of the outer join
    with dept_tbl as (select 1 dept_id, SYSDATE effdt FROM DUAL),
         tips_tbl as (select 1 dept_id, NULL effdt FROM DUAL)
    select a.effdt
      from dept_tbl a,
           tips_tbl b
    where b.dept_id(+) = a.dept_id
       and NVL(b.effdt, SYSDATE) = NVL((select max(b_ed.effdt)
                                          from tips_tbl b_ed
                                         where b.dept_id = b_ed.dept_id
                                           and b_ed.effdt <= SYSDATE), SYSDATE);
    EFFDT
    5/7/2007 3:25:00 PM

  • Problem with outer join with filter on join column

    Hi,
    In physical layer I have one dimension and two facts, and there's an outer join between the facts.
    dim_DATE ,
    fact_1 ,
    fact_2
    Joins:
    dim_DATE inner join fact_1 on dim_DATE.DATE = fact_1.DATE
    fact_1 left outer join fact_2 on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
    When I run a report with a date as a filter, OBIEE executes "optimized" physical SQL:
    select fact1.X, fact2.Y
    from
    Fact_1 left outer join on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
    where Fact_1.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD' )
    and  Fact_2.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD')
    The filter on Fact_2.DATE effectively replaces outer join with inner.
    Is there a way to disable this "optimization", which is actually very good for inner joins, but doesn't allow outer joins?
    Thanks in advance,
    Alex
    Edited by: AM_1 on Aug 11, 2009 8:20 AM

    If you want to perform a Fact-based partitioning with OBIEE (two fact with the same dimension), you have to :
    * create in your physical layer for each fact table the joins with the dimension
    * create in the Business Model layer ONE star schema with ONE logical fact table containing the columns of your two physical fact table
    In this way when you choose minimal one column of your fact1 and one column of your fact2, OBIEE will perform two query against each fact table/dimension, join them with an OUTER JOIN and your problem will disappear.
    Cheers
    Nico

  • 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

  • Outer Join with Where Clause in LTS

    HI all,
    I have a requirement like this in ANSI SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1 left outer join product_group p2 on p1.product_id = p2.product_id
    and p2.product_group = 'NEW'
    In Regular SQL:
    select p1.product_id, p1.product_name, p2.product_group
    from product p1, product_group p2
    WHERE p1.product_id *= p2.product_id and p2.product_group = 'NEW'
    In OBIEE, I am using a left outer join between these two in Logical table Source, and also, Gave
    p2.product_group = 'NEW' in WHERE clause of LTS.
    This doesn't seem to solve purpose.
    Do you have any idea how to convert WHERE clause in physical query that OBIEE is generating to something like
    product p1 left outer join product_group p2 on p1.product_id = p2.product_id AND p2.product_group = 'NEW'
    I am using Version 10.1.3.4.1
    Creating an Opaque view would be my last option though.

    Hello
    I have read your post and the responses as well. and I understand that you have issues with the Outer Join with where Clause in LTS.
    Try this solution which worked for me (using your example ) -
    1. In the Physical Layer created a Complex join between PRODUCT and PRODUCT_GROUP tables and use this join relationship :
    PRODUCT.PROD_ID = PRODUCT_GROUP.PROD_ID  AND  PRODUCT_GROUP.GROUP_NAME = 'MECHANICAL' 
    2. In the General Tab of PRODUCT table LTS add PRODUCT_GROUP  table and select Join Type as Left Outer Join.
    3. Check Consistency and make sure there are no errors .
    when you run a request you should see the following query generated -
    select distinct T26908.PROD_ID as c1,
         T26908.PROD_NAME as c2,
         T26912.GROUP_NAME as c3
    from
         PRODUCT T26908 left outer join PRODUCT_GROUP T26912 On T26908.PROD_ID = T26912.PROD_ID and T26912.GROUP_NAME = 'MECHANICAL'
    order by c1, c2, c3
    Hope this works for you. If it does please mark this response as 'Correct' .
    Good Luck.

  • 11g outer join with case statement - strange results.

    Hello All,
    I am experiencing a strange issues in 11g while using case statement.
    I am not able to reproduce this using sample data. Not sure what is wrong.
    I am not narrowing it to say the usage of case statemnt is giving wrong results, but that is my observation when I am doing trail and error testing.
    Here are the details.
    My Version
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SQL> My Query
    SELECT *
      FROM (SELECT DISTINCT mf.schedule,
                            mf.cptcode,
                            NVL (mf.modifier, '00') modifier2,
                            CASE
                               WHEN mf.feetype = 'H'
                                AND mf.multiplier IS NOT NULL THEN
                                  '      0.00'
                               WHEN (mf.feetype != 'H'
                                  OR  mf.feetype IS NULL)
                                AND mf.rbrvsvalue IS NOT NULL
                                AND mf.multiplier IS NOT NULL THEN
                                  LPAD ( TRIM (TO_CHAR ( (mf.rbrvsvalue * mf.multiplier) / 100, 9999999.99)), 10)
                               ELSE
                                  NULL
                            END
                               fee
              FROM provider.mpifee mf, mpi_udffee.udffeeactivecptcodes vld
             WHERE mf.schedule = 'SAPG1'
               AND mf.cptcode = vld.cptcode
               AND NVL (mf.modifier, 'NULL') = NVL (vld.modifier, 'NULL')) inline_fee,
           (SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
              FROM mpi_udffee.udffeeancfeedata arc
             WHERE monthofextract = '201202'
               AND arc.schedule = 'SAPG1'
               AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate) inline_data
    WHERE inline_fee.schedule = inline_data.col1(+)
       AND inline_fee.cptcode = inline_data.col2(+)
       AND inline_fee.modifier2 = inline_data.col3(+);
    In the above query the inline view inline_data returns zero rows. but NVL is still getting applied for col3 and I am getting 00 in the results( strange ).
    Results:
    SCHEDULE        CPTCO MODIFIER2  FEE             COL1  COL2  COL3
    SAPG1           49590 00             667.32                  00
    SAPG1           49611 00             781.03                  00
    SAPG1           49905 00             443.79                  00
    SAPG1           50205 00             883.56                  00
    SAPG1           50220 00            1315.15                  00
    SAPG1           50230 00            1638.74                  00
    SAPG1           50234 00            1666.16                  00
    SAPG1           50250 00            1566.14                  00
    SAPG1           50327 00             262.04                  00
    SAPG1           50541 00            1183.31                  00
    SAPG1           50620 00            1156.88                  00
    SAPG1           50650 00            1321.96                  00
    497 rows selected.
    Just the inline view inline_data,
    SQL> SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
      2            FROM mpi_udffee.udffeeancfeedata arc
      3           WHERE monthofextract = '201202'
      4             AND arc.schedule = 'SAPG1'
      5             AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate;
    no rows selectedMuch unusual thing is when I just remove the case statement from the inline view "inline_fee", I am getting right results,
    SELECT *
      FROM (SELECT DISTINCT mf.schedule,
                            mf.cptcode,
                            NVL (mf.modifier, '00') modifier2          <-- Removed Case statement here
              FROM provider.mpifee mf, mpi_udffee.udffeeactivecptcodes vld
             WHERE mf.schedule = 'SAPG1'
               AND mf.cptcode = vld.cptcode
               AND NVL (mf.modifier, 'NULL') = NVL (vld.modifier, 'NULL')) inline_fee,
           (SELECT arc.schedule col1, arc.procedurecode col2, NVL (arc.modifier, '00') AS col3
              FROM mpi_udffee.udffeeancfeedata arc
             WHERE monthofextract = '201202'
               AND arc.schedule = 'SAPG1'
               AND TRUNC (SYSDATE - 10) BETWEEN arc.recordeffectivedate AND arc.recordterminationdate) inline_data
    WHERE inline_fee.schedule = inline_data.col1(+)
       AND inline_fee.cptcode = inline_data.col2(+)
       AND inline_fee.modifier2 = inline_data.col3(+);
    SCHEDULE        CPTCO MODIFIER2  COL1  COL2  COL3
    SAPG1           46730 00
    SAPG1           46735 00
    SAPG1           46748 00
    SAPG1           46760 00
    SAPG1           46942 00
    SAPG1           46945 00
    SAPG1           47015 00
    SAPG1           47125 00
    SAPG1           47350 00
    SAPG1           47505 00
    SAPG1           47553 00interestingly explain plan for both the statements are exactly same,
    SELECT STATEMENT  ALL_ROWSCost: 138  Bytes: 1,078,274  Cardinality: 11,471                                
         9 HASH JOIN RIGHT OUTER  Cost: 138  Bytes: 1,078,274  Cardinality: 11,471                           
              2 PARTITION RANGE EMPTY  Cost: 2  Bytes: 150  Cardinality: 3                      
                   1 TABLE ACCESS FULL TABLE MPI_UDFFEE.UDFFEEANCFEEDATA Cost: 2  Bytes: 150  Cardinality: 3                 
              8 VIEW MPI_UDFFEE. Cost: 135  Bytes: 504,724  Cardinality: 11,471                      
                   7 HASH UNIQUE  Cost: 135  Bytes: 539,137  Cardinality: 11,471                 
                        6 HASH JOIN  Cost: 134  Bytes: 539,137  Cardinality: 11,471            
                             3 TABLE ACCESS FULL TABLE MPI_UDFFEE.UDFFEEACTIVECPTCODES Cost: 13  Bytes: 177,345  Cardinality: 25,335       
                             5 PARTITION LIST SINGLE  Cost: 120  Bytes: 600,600  Cardinality: 15,015  Partition #: 8       
                                  4 INDEX RANGE SCAN INDEX (UNIQUE) REPRICE.PK_MPIFEE Cost: 120  Bytes: 600,600  Cardinality: 15,015  Partition #: 9  Partitions accessed #11Is there anything wrong with the query? If not have anyone come across this issue or posted it as a bug or is there a patch?
    Update:
    when I set the parameter "_complex_view_merging"=false I am getting the right results even with case statement. But I don want to do some thing unsupported.
    Are there any other viable solutions?
    I appreciate the help.
    Thanks,
    G.
    Edited by: Ganesh Srivatsav on Apr 10, 2012 12:37 PM

    Hi Tubby,
    Right, the query transformation is going wrong. Following is from trace,
    SELECT "INLINE_FEE"."SCHEDULE" "SCHEDULE",
           "INLINE_FEE"."CPTCODE" "CPTCODE",
           "INLINE_FEE"."MODIFIER2" "MODIFIER2",
           "INLINE_FEE"."FEE" "FEE",
           "ARC"."SCHEDULE" "COL1",
           "ARC"."PROCEDURECODE" "COL2",
           CASE
              WHEN "ARC".ROWID IS NOT NULL THEN NVL ("ARC"."MODIFIER", '00')
              ELSE NULL
           END
              "COL3"
      FROM (SELECT DISTINCT "MF"."SCHEDULE" "SCHEDULE",
                            "MF"."CPTCODE" "CPTCODE",
                            NVL ("MF"."MODIFIER", :B2) "MODIFIER2",
                            CASE
                               WHEN ("MF"."FEETYPE" = :B3
                                 AND "MF"."MULTIPLIER" IS NOT NULL) THEN
                                  :B4
                               WHEN ( ("MF"."FEETYPE" <> :B5
                                    OR  "MF"."FEETYPE" IS NULL)
                                 AND "MF"."RBRVSVALUE" IS NOT NULL
                                 AND "MF"."MULTIPLIER" IS NOT NULL) THEN
                                  LPAD ( TRIM (TO_CHAR ( "MF"."RBRVSVALUE" * "MF"."MULTIPLIER" / :B6, :B7)), :B8)
                               ELSE
                                  NULL
                            END
                               "FEE"
              FROM "PROVIDER"."MPIFEE" "MF", "MPI_UDFFEE"."UDFFEEACTIVECPTCODES" "VLD"
             WHERE "MF"."SCHEDULE" = 'SAPG1'
               AND "MF"."CPTCODE" = "VLD"."CPTCODE"
               AND NVL ("MF"."MODIFIER", 'NULL') = NVL ("VLD"."MODIFIER", 'NULL')) "INLINE_FEE",
           "MPI_UDFFEE"."UDFFEEANCFEEDATA" "ARC"
    WHERE "INLINE_FEE"."SCHEDULE" = "ARC"."SCHEDULE"(+)
       AND "INLINE_FEE"."CPTCODE" = "ARC"."PROCEDURECODE"(+)
       AND "INLINE_FEE"."MODIFIER2" = CASE
                                         WHEN ("ARC".ROWID(+) IS NOT NULL) THEN NVL ("ARC"."MODIFIER"(+), '00')
                                         ELSE NULL
                                      END
       AND "ARC"."MONTHOFEXTRACT"(+) = '201202'
       AND "ARC"."SCHEDULE"(+) = 'SAPG1'
       AND TRUNC (SYSDATE-10) >= "ARC"."RECORDEFFECTIVEDATE"(+)
       AND TRUNC (SYSDATE-10) <= "ARC"."RECORDTERMINATIONDATE"(+)Does this refer to a specific bug?
    Thanks,
    G.

  • Outer join With a constant value

    Hi all,
    In one of query i have found out that the outer join with a constant value like
    to_currency(+)='USD'
    to_currency is a column name in a table.can any one please explain this outer join condtn.
    Thanks in advance
    Senthil

    Hallo,
    if you write var (+) = constant
    var can be equal constant, and also can be null
    Compare these 2 queries
    select e.* from scott.emp e, scott.dept d
    where e.deptno = d.deptno(+)
    and d.deptno(+) = 10EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7369     SMITH      CLERK      7902     17-Dez-1980     800          20
    7499     ALLEN      SALESMAN      7698     20-Feb-1981     1600     300     30
    7521     WARD      SALESMAN      7698     22-Feb-1981     1250     500     30
    7566     JONES      MANAGER      7839     2-Apr-1981     2975          20
    7654     MARTIN      SALESMAN      7698     28-Sep-1981     1250     1400     30
    7698     BLAKE      MANAGER      7839     1-Mai-1981     2850          30
    7782     CLARK      MANAGER      7839     9-Jun-1981     2450          10
    7788     SCOTT      ANALYST      7566     19-Apr-1987     3000          20
    7839     KING      PRESIDENT           17-Nov-1981     5000          10
    7844     TURNER      SALESMAN      7698     8-Sep-1981     1500     0     30
    7876     ADAMS      CLERK      7788     23-Mai-1987     1100          20
    7900     JAMES      CLERK      7698     3-Dez-1981     950          30
    7902     FORD      ANALYST      7566     3-Dez-1981     3000          20
    7934     MILLER      CLERK      7782     23-Jan-1982     1300          10
    select e.* from scott.emp e, scott.dept d
    where e.deptno = d.deptno(+)
    and d.deptno = 10 EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7782     CLARK      MANAGER      7839     9-Jun-1981     2450          10
    7839     KING      PRESIDENT           17-Nov-1981     5000          10
    7934     MILLER      CLERK      7782     23-Jan-1982     1300          10
    As you can see, this (+) is very important
    Regards
    Dmytro

  • Outer Join with an 'OR'

    I have a very complicated query to construct that requires the use of 'AND', 'OR', and Outer Joins. Oracle's 9i documentation says you can't use an outer join with an 'OR'.
    Can you suggest how I may return the correct records under the following conditions. There are 3 tables to join. Table A, Table B, and Table C. Tables A & B join with an = to common fields. The problem is with Table C.
    The way the application was designed, it has to track a parent and child relationship. As such, the field to relate may exist in 1 of 2 fields. Let's see if I can draw it out for you.
    Table A - Record 1
    (ID = 1)
    Table B - Record 1
    (ID =1 [this relates to Table A.ID]
    PID = 12345
    CID = 67899
    Site = A)
    Table C - Record 1
    (PID = 12345 [this relates to Table B.PID]
    CID = 67899
    Site = A)
    Table C - Record 2
    (PID = 67899 [This relates to Table B.CID]
    CID = 12345
    Site = A)
    Now, I need to relate Table A to Table B where A.ID = B.ID AND
    ((B.PID = C.PID AND B.CID = C.CID)
    OR
    (B.CID = C.PID AND B.PID = C.CID))
    AND
    B.SITE = C.SITE
    There may or may NOT be related records in Table C. That's the problem. This is where I need the outer join to get the all the records of the 1st two joins and only those that apply from the last join.
    Your help will be greatly appreciated.

    I'd create two queries, a join from b to c in each of those manners and then UNION ALL the results together.
    drop table junk_a;
    create table junk_a (
      id number );
    drop table junk_b;
    create table junk_b (
      id number,
      pid number,
      cid number,
      site varchar2(80) );
    drop table junk_c;
    create table junk_c (
      pid  number,
      cid  number,
      site  varchar2(80) );
    insert into junk_a values (1);
    insert into junk_b values (1, 12345, 67899, 'A');
    insert into junk_c values (12345, 67899, 'A');
    insert into junk_c values (67899, 12345, 'A');
    commit;
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.pid(+) = b.pid
       AND c.cid(+) = b.cid
    UNION ALL
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.cid(+) = b.pid
       AND c.pid(+) = b.cid;
    SELECT a.id,
           bc.pid,
           bc.cid,
           bc.site,
           bc.site_c
      FROM junk_a  a,
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.pid(+) = b.pid
       AND c.cid(+) = b.cid
    UNION ALL
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.cid(+) = b.pid
       AND c.pid(+) = b.cid
           )  bc
    WHERE bc.id(+) = a.id;

  • Outer join with BETWEEN clause

    Hi All,
    I have 2 tables (A and B) which i need to join. I need all records from table A and matching records from the table B. below is the structure.
    TABLE A (total rows = 10)
    ROW_WID
    GL_DATE
    LOCATION_CODE
    TABLE B (total = 7)
    ROW_WID
    START_DATE
    END_DATE
    LOCATION_CODE
    Initially, we were asked to join based on location_code. In the table B, some of the LOCATION_CODE are missing, which is present in table A.
    We wrote below query
    SELECT A.*, B.START_DATE, B.END_DATE
    FROM A, B
    WHERE A.LOCATION_CODE = B.LOCATION_CODE (+)
    This gives 10 records, where 3 records have START_DATE and END_DATE NULL. because of outer join
    It gave all records from the A table. It worked fine. Now i need to add one more condition where A.GL_DATE between B.START_DATE and B.END_DATE
    If i write this
    SELECT A.*, B.START_DATE, B.END_DATE
    FROM A, B
    WHERE A.LOCATION_CODE = B.LOCATION_CODE (+)
    AND A.GL_DATE BETWEEN B.START_DATE and B.END_DATE
    This gives me only 7 records. IS IT POSSIBLE TO ADD OUTER JOIN with BETWEEN clause.

    Hi All,
    I'm in a similar situation,
    I have a complex query, everything is working fine, except this part (I will simplify everything, removing other stuffs because I need help only on the following condition)
    SELECT *
    from transaction t, card c
    where c.card_id = t.card_id (+)
    and t.trn_date between to_date ('01/01/2012','dd/mm/yy') and ('01/01/2013,'dd/mm/yy')
    How could i OUTER JOIN the between condition?
    I tried with
    and t.trn_date between to_date ('01/01/2012','dd/mm/yy') (+) and ('01/01/2013','dd/mm/yy') (+)
    but returns a "missing expression" error.
    Surely I'm missing some stupid thing about it, could you help me on this? (probably because I'm talking about parameters and I cannot put the outer join on a value)
    How can I rewrite the condition in order to satisfy what I'm trying to accomplish?
    Thanks in Advance,
    Alex
    Edited by: 981667 on 14-gen-2013 4.23
    Edited by: 981667 on 14-gen-2013 4.24

  • How to achieve an outer join with existsNode() function

    I have a requirement to do an outer join with existsNode() function in my where clause. At present my where clause for join is like below
    WHERE A.SOME_ID= “XYZ”
    AND existsNode (B.SOMEXML_FEILD , …. ) = 1
    AND existsNode (C.SOMEOTHERXML_FEILD , …. ) = 1
    In this case if the existsNode fails on B or C, I still want data from A to be selected. How to rewrite this query to achieve that? I kinda want to achieve an outer join

    Hi,
    is this what you are looking for:
    SQL> with t as(select 1 id1,'A' name from dual union all
      2            select 2 ,'B' name from dual union all
      3            select 3,'C' from dual)
      4      ,x as(select 1 id2,xmltype('<a>a</a>') xcol from dual union all
      5            select 2 ,xmltype('<b>b</b>') xcol from dual)
      6  select *
      7  from t,x
      8  where t.id1=x.id2(+)
      9    and (existsNode(x.xcol,'/a')=1 or x.xcol is null);
           ID1 N        ID2 XCOL                                                   
             1 A          1 <a>a</a>                                               
             3 C                                                                   
    SQL> spool off;

  • Case statement resulting into Left outer join with other tables

    Hi All ,
    I am facing a stuation where a Case statement on one of the logical columns in Answers is resulting into a left outer join with a table in the query.
    If we remove the case stmt, the table is not being acessed.
    The case stmt is a simple one and no other logical column is being accessed in the case stmt.
    Please advice .
    Thanks.

    Hi Sai,
    No ..we dont have any left outer join ...its just that I am selecting measure from F1 which has a confimred dimension D1 with F2.Now when I dont have case stmt on measure from F1(Case stmt is something like : CASE WHEN "- P table"."P Column" = 'Y' THEN 'Right' ELSE 'Wrong' END), then it doesnt query F2.
    However as soon as I introduce the case stmt ,the query creates a left outer join with F2.
    Thanks.

  • Content Tab: None of the fact tables are compatible with the query request

    Hi All,
    **One thing I am not clear yet of all my years with OBIEE is working with the content tab in BMM.**
    I have made a rpd the joins in physical layer as shown below:
    https://picasaweb.google.com/114804305606242416264/OBIEEError#5663056545119428530
    And the BMM layer as:
    https://picasaweb.google.com/114804305606242416264/OBIEEError#5663056519553812930
    Error I am getting when i run a request from the 3 columns from the selected 3 tables is:
    Dim - Comment Code Details
    Fact - Complaint
    Dim - Service Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 14020] None of the fact tables are compatible with the query request Sr Num:[DAggr(Fact - Complaint.Sr Num by [ Dim - Service Details.Sr Cat Type Cd, Dim - Comment Code Details.Cmtcode name] )]. (HY000).
    I get no error for consistency.. I read everywhere and I know i need to set the appropriate aggregation levels in the various dims and facts LTS properties to help OBIEE understanding our model, but how to do that.. how do i decide... how should I approach, what should be the aggregation level, what details.
    When i click More button i see different options: Copy, Copy From, Get Levels, Check Level, what do these mean.
    Aggregation Content, group by - Logical Level or Column which one should i choose and how should I decide.
    Can anyone explain the Content Tab in details and from scratch with some example and why we get these errors.... I know many people who are well versed with many other things related to RPD but this. A little efforts of explaining from you guys will really be appreciated.
    Thanks in advance,
    Dev

    Hi Deepak,
    Option 1:
    My tables in physical layer are joined as below:
    D1--> F1 <--D2--> F2 <--D3
    Same way i model it in BMM
    D1--> F1 <-- D2--> F2 <--D3
    Here D1 is non Conformed Dimension for F2 and D3 is non Conformed dim for F1. Later create Dimensional hierarchies, I tried setting up the content levels
    I go Sources>content tab of Fact F1 I set
    Dimensions----------- Logical level
    D1---------------------- D1 Detail
    D2---------------------- D2 Detail
    D3---------------------- D3 Total
    then, I go Sources>content tab of Fact F2 I set
    Dimensions----------- Logical level
    D1---------------------- D1 Total
    D2---------------------- D2 Detail
    D3---------------------- D3 Detail
    Then, I also go in all the dimensions and set their content levels to Details, but it still gives me errors not sure where I am going wrong in setting the content levels.
    I need to know whether the way I have modeled it in BMM is right,
    Option 2:
    I can combine the two facts in a single Logical Fact or the above design should also work.
    (F1&F2)<--D1, D2 , D3 joined separately using complex logical joins.
    what will be the content tab details?
    Thanks,
    Dev

  • SSMS 2012:XQuery-doing "Retriving Job Candidates with the query Method" in AdventuresWorks 2012. Unclosed quotation mark after string '//*:Name.First?

    Hi all,
    From Page 354 of the the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles (published by apress), I copied the following code (Listing 12-9 Retrieving Job Candidates with the query Method):
    --Coles12_9.sql // saved in C:/Documemnts/SQL Server Management Studio
    -- Coles Listing 12-9 Retrieving Job Candidates with the query Method
    -- Doing XQuery and the xml Data Type in AdvantureWorks
    -- 17 March 2015 1105 AM
    USE AdventureWorks;
    GO
    SELECT Resume.query
    N'//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    I executed this set of Listing 12-9 code in my SQL Server 2012 Management Studio and I got the following error messages:
    Msg 105, Level 15, State 1, Line 4
    Unclosed quotation mark after the character string '//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    Msg 102, Level 15, State 1, Line 4
    Incorrect syntax near '//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    I am not able to figure out why I got the error messages.  Please kindly help and advise me how to correct this set of sql codes.
    Thanks in advance,
    Scott Chang

    Hi Scott,
    I don't have that book at hand, but your problem is the "Unclosed quotationmark after the character string",as the error message shows. You have to enclose the 'XQUERY' string quotation in the
    query().
    SELECT jobcandidateid, Resume.query
    N'//*:resume,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level' --enclose the quotation here
    FROM HumanResources.JobCandidate;
    For XQUERY learning, here is a good
    link.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for

  • Can't make a New Event in Calendar. Why?

    My iMac is running OSX 10.8.2. My iPhone 4S is running 6.1.1. My iPad is running 6.1. If I try to enter a 'New Event' on my iMac I always get the following message: 'The server responded with "400" to operation CalDAVWriteEntityQueueableOperation' Th

  • How do I email a scanned document for pixma pringting soloutions

    I just got set up and scanned a document using my canon mg3520 all in one printer to my ipad air and I want to email it but can't figure out how to

  • Vibration Mode Not Working

    I have Pearl 8130 that is approximately 13 months old (just out of warranty of course) and the vibration mode quit working.  The day that it quit working I received a call in the morning and it worked. That afternoon no more vibration it had been on

  • Advising record (ADV - HSBC form) in DME file could not get email address

    Dear all, I have problems with DME file that Advising record could not get email that is maintained in vendor master data. Standard communication methods in vendor master data must be Emails. We use exit module to get this email for below fields: Ema

  • JDeveloper 11g can't run Web application locally

    Hi, I'm trying to run a simple Web Application with the integrated Weblogic, but it seems that JDev can't deploy the dependents jars. For example. I have this project that has the oracle.ucm.ridc.11.1.jar file in the Library Classpath. When I try to