Nested join with left - question

Hi Experts,
I have a special query requirement
Here are the three tables A, B & C
TABLE-A
A_ID
Type
A1
Call
A2
Web
A3
Call
A4
TV
A5
TV
TABLE-B
B_ID
Ord_Type
A_ID
B1
US
A3
B2
DE
A4
B3
UK
A5
TABLE-C
C_ID
B_ID
C_VAL
C1
B1
10
C2
B3
20
I need to write  a query to get the following results
Total A
Total Bs with Val
Sum C_VAL
5
2
30
So want to include all rows from A and include only the rows from B that has a corresponding value in C.
Would someone please help?
Thanks,
AP

with
table_a as
(select 'A1' a_id,'Call' a_type,101 proj from dual union all
select 'A2','Web',101 from dual union all
select 'A3','Call',101 from dual union all
select 'A4','TV',101 from dual union all
select 'A5','TV',101 from dual union all
select 'A6','ABC',201 from dual union all
select 'H5','ABC',301 from dual
table_b as
(select 'B1' b_id,'US' ord_type,'A3' a_id from dual union all
select 'B2','DE','A4' from dual union all
select 'B3','UK','A5' from dual union all
select 'B4','UK','H5' from dual union all
select 'B5','UK','' from dual
table_c as
(select 'C1' c_id,'B1' b_id,10 c_val from dual union all
select 'C2','B3',20 from dual union all
select 'C3','B4',40 from dual
select max(a.total) total_a,
       count(*) b_ids_in_c,
       sum(c.c_val) sum_c_val
  from (select a_id,
               count(*) over (partition by proj) total
          from table_a
         where proj = 101
       ) a,
       table_b b,
       table_c c
where a.a_id = b.a_id
   and b.b_id = c.b_id
TOTAL_A
B_IDS_IN_C
SUM_C_VAL
5
2
30
Regards
Etbin

Similar Messages

  • RCD join with TCD question

    When I search the RCD table for a specific date range and calltypeid, the number is always slightly lower than the TCD table filtering on the same date range and calltypeid, but also filtering on the peripheralcalltype of 2 and peripheralid of the agent pim (only the agent leg of routed calls which are only inbound acd calls in this instance).
    The goal being to capture some additional information about the calls that is in the TCD but not the RCD, but also this particular customer requires the call counts to match what they're getting in their skill_group/skill_group_interval reports. So if I start with the RCD and pull in the additional data from the TCD table, that seems to be the most appropriate solution.
    ...but I don't know how to join to the TCD pulling in the data from the agent leg only. I don't need any data from transfers, conferences, etc. Just the one row.
    Any help would be appreciated.
    thanks,
    will

    Will,
    You can join data from the same call by matching RouterCallKeyDay and RouterCallKey between the two tables. You could probably ensure the CallTypeID is the same between both as well, for good measure.
    Agent leg only should be fairly straightforward... try:
    WHERE TCD.AgentSkillTargetID IS NOT NULL
    Perhaps also match on TCD.AgentPeripheralNumber (or maybe InstrumentPortNumber) = RCD.Label... this would rule out potential duplicates from transfers to the same Call Type, or RONAs without a Call Type change.
    Now... the only potential problem I see here which may cause a little difficulty - in my experience, I see a lot of TCD entries where (within the same RouterCallKey-RouterCallKeyDay combo in TCD) the CallTypeID is NOT on the same RouterCallKeySequenceNumber entry as the AgentSkillTargetID. So, you may have to join to the TCD table twice if you're filtering on CallTypeID and just want the agent leg. If you want to bring in data such as the Call GUID as well, you will likely be forced to do multiple joins like this as I'm not sure I've ever seen Call GUID on the Agent leg in TCD.
    -Jameson

  • Update Statement with left outer join

    hi,
    i have to update a column in table "a" from table "b" and both of them joined with left outer join
    How can I do this
    Thanks in Advance

    Please consider the following when you post a question. This would help us help you better
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 3 tables with left joins - bug?

    Hello,
    i am making query where i encounter problem with left join in oracle. I am using oracle 10g and i prepare simple test case.
    he is testing tables and datas - really simple i think:
    drop table t1;
    drop table t2;
    drop table t3;
    create table t1 (a number not null);
    create table t2 (a number, b number);
    create table t3 (b number);
    insert into t3 values (1);
    insert into t3 values (2);
    insert into t3 values (3);
    insert into t1 (a) values (1);
    insert into t2 (a,b) values (1,1);
    insert into t1 (a) values (2);
    insert into t2 (a,b) values (2, null);
    insert into t1 (a) values (3);
    insert into t1 (a) values (4);
    insert into t2 (a,b) values (4,1);
    insert into t1 (a) values (5);
    insert into t2 (a,b) values (5,3);
    and now query with left joins:
    select
    t1.a
    , t2.a, t2.b
    , t3.b
    from
    t1, t2, t3
    where
    t1.a = t2.a (+)
    and t2.b = t3.b (+)
    and t3.b is null
    order by t1.a
    i get two rows as result:
    A A_1 B B_1
    2 2 null null      
    3 null null null                
    i expect these rows but when i change my query - i dont want get back t3.b column:
    select
    t1.a
    , t2.a, t2.b
    /* , t3.b*/
    from
    t1, t2, t3
    where
    t1.a = t2.a (+)
    and t2.b = t3.b (+)
    and t3.b is null
    order by t1.a
    i get only one row
    A A_1 B
    2 2 null
    My question is simple how can i only by changing columns getting back change number of returned rows? I must say i dont expect these result i expect two rows again.
    Thanks for help.

    BluShadow wrote:
    I think I know what you are getting at.
    By testing for null on t3.b when you aren't selecting the column, you are enforcing oracle to perform the join through t2 onto t1, but Oracle can't join because t2 has no matching row (although it's outer joined to t1) and therefore, for the one row it can't actually determine if t3.b is null or not, so that row can't match the conditions in a "true" sense and be displayed. If you select the column then oracle can test its nullness ok. (Perhaps this is a bug, I don't know, it's just how I know it works)If you get different results only by changing the projection part of the query this is a bug and nothing else. I can't reproduce using Oracle 10g XE, I get in both cases shown the expected two rows.
    What versions are you using to test this?
    SQL>
    SQL> select * from v$version
      2  where rownum <= 1;
    BANNER
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    SQL>
    SQL> drop table t1 purge;
    Table dropped.
    SQL> drop table t2 purge;
    Table dropped.
    SQL> drop table t3 purge;
    Table dropped.
    SQL>
    SQL> create table t1 (a number not null);
    Table created.
    SQL> create table t2 (a number, b number);
    Table created.
    SQL> create table t3 (b number);
    Table created.
    SQL>
    SQL> insert into t3 values (1);
    1 row created.
    SQL> insert into t3 values (2);
    1 row created.
    SQL> insert into t3 values (3);
    1 row created.
    SQL>
    SQL> insert into t1 (a) values (1);
    1 row created.
    SQL> insert into t2 (a,b) values (1,1);
    1 row created.
    SQL>
    SQL> insert into t1 (a) values (2);
    1 row created.
    SQL> insert into t2 (a,b) values (2, null);
    1 row created.
    SQL>
    SQL> insert into t1 (a) values (3);
    1 row created.
    SQL>
    SQL> insert into t1 (a) values (4);
    1 row created.
    SQL> insert into t2 (a,b) values (4,1);
    1 row created.
    SQL>
    SQL> insert into t1 (a) values (5);
    1 row created.
    SQL> insert into t2 (a,b) values (5,3);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select t1.a
      2       , t2.a, t2.b
      3       , t3.b
      4  from
      5         t1 left outer join t2 on (t1.a = t2.a)
      6            left outer join t3 on (t2.b = t3.b)
      7  where t3.b is null
      8  order by t1.a;
             A          A          B          B
             2          2
             3
    SQL>
    SQL> select t1.a
      2       , t2.a, t2.b
      3  --     , t3.b
      4  from
      5         t1 left outer join t2 on (t1.a = t2.a)
      6            left outer join t3 on (t2.b = t3.b)
      7  where t3.b is null
      8  order by t1.a;
             A          A          B
             2          2
             3
    SQL>Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Oracle 8i, left join with conditional

    Coming from the MySQL world, I'm trying to do a left join with a
    condition:
    select c.givenname,c.surname,c.userid,r.letternr
    from cand c,responses r
    where (c.userid=r.username(+))
    and
    c.activeprofile=1
    No problem whatsoever.
    If there is no corresponding "response" in R for a given
    candidate, I get a NULL return for R.letternr.
    However, there is a flag in R, called "VISIBLE" that I wish to
    use to mean "Don't count this entry in R". R.VISIBLE=0 means
    that the response is not active/present/visible/valid.
    Am I making any sense? :-)

    If you don't want to display a row with a null value for
    r.letternr when r.visible = 0, then:
    SELECT     c.givenname,
               c.surname,
               c.userid,
               r.letternr
    FROM       cand c,
               responses r
    WHERE      c.userid = r.username (+)
    AND        c.activeprofile = 1
    AND        r.visible != 0
    Or, if you do want to display a row with a null value for
    r.letternr when r.visible = 0, then:
    SELECT     c.givenname,
               c.surname,
               c.userid,
               r.letternr
    FROM       cand c,
               responses r
    WHERE      c.userid = r.username (+)
    AND        c.activeprofile = 1
    AND        r.visible (+) != 0

  • ANSI Standard Join with Nested Table

    Does anyone know how to (or whether you actually can) use ansi standard table joins with nested tables.
    Non-ansi standard would look something like this
    SELECT e.empno
    FROM departments d, TABLE(d.employees) e
    WHERE d.deptno = 10;
    Where d.employees is a nested table.
    But if I try ansi-standard I like such:
    SELECT e.empno
    FROM departments d
    JOIN TABLE(d.employees) e
    WHERE d.deptno = 10;
    I get
    ORA-00905: missing keyword
    because I have nothing to join it on.
    Your help is very much appreciated

    Both replies worked fine.
    I think I will go with the NATURAL JOIN as it seems the cleanest option.
    Thanks Guru 2748

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

  • Help in joining nested table with regular table

    Im creating a nested table codelist as object prtcnpt_info. In a anonymous block im declaring t_code as nested table type codelist.
    Now when i try to join the nested table with the regular oracle DB table and i get error: PL/SQL: ORA-00904: "COLUMN_VALUE": invalid identifier.
    Please help me on this and provide tutorial link pertaining to this concepts..Below is the code i wrote
    --Code Start;
    create or replace type prtcnpt_info as object ( id number
    ,name varchar2(200)
    ,code varchar2(30));
    create type codelist is table of prtcnpt_info;
    declare
    t_code codelist;
    begin
    select prtcnpt_info(b.pid ,b.name ,pt.code) bulk collect into t_code
    from part pt
    ,mc_code b
    where pt.cd in ('AAA','BBB')
    and pt.ptype_id=b.pt_type_id;
    INSERT INTO table ( ID
    ,RUN_ID
    ,DATA
    ,P_ID
    SELECT id
         ,run_id
         ,data
         ,prtct.id ----> 1
    FROM table_2 t2
    ,(select column_value from table(t_code)) prtct
    WHERE prtct.id=t2.P_ID; ------> 2
    end;
    --Code End;
    also from the anonymous block
    1 => is this correct way to get value of id (b.pid) from the nested tablet_code aliased as prtct ?
    2 => is this correct way to join the nested table with regular table? i want to join the column id's in both the tables.
    Edited by: 914912 on Apr 30, 2012 2:11 AM

    When you create a table type without an object, i.e. a single column type like this you will get the column name as COLUMN_VALUE.
    SQL*Plus: Release 10.2.0.5.0 - Production on Mon Apr 30 07:38:32 2012
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> create or replace type mytbl as table of varchar2(10)
      2  /
    Type created.
    SQL> var rc refcursor
    "afiedt.buf" 11 lines, 162 characters
      1  declare
      2     ltbl mytbl;
      3  begin
      4     select to_char(level) bulk collect into ltbl
      5       from dual
      6    connect by level <= 10;
      7     open :rc for
      8     select * from table(ltbl);
      9* end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> print rc
    COLUMN_VAL
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    10 rows selected.And when you create a table type with object you will get the object column name.
    SQL> drop type mytbl
      2  /
    Type dropped.
    SQL> create type myobj as object (id varchar2(10))
      2  /
    Type created.
    SQL> create type mytbl as table of myobj
      2  /
    Type created.
    SQL> declare
      2     ltbl mytbl;
      3  begin
      4     select myobj(to_char(level)) bulk collect into ltbl
      5       from dual
      6    connect by level <= 10;
      7     open :rc for
      8     select * from table(ltbl);
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> print rc
    ID
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    10 rows selected.
    SQL>

  • Using nested Joins in abap prog

    Hi All,
    please help me  out in using nested joins in abap progrmaming. I dont know about joins in abap.specially in case of outer join.
      I have 5 internal tables.. mara ,marc, mvke,mbew,ampl. am using  a  select query with certain fields from all these tables.
      I need to disply  all the materials  of  a mara for  a particular date irrespective of  the values in fields of  other tables.
            Even if that materail is not present in other table for certain condtion ,that material  should get displyed with all other fields  showing null value..

    Hi RK,
    the  code am using is of the same way...but my problem was with the joins..in the  select query  am using nested join combining inner  and outer join.. but i could  not able to display all the materials  of mara of a particular date..
    The code looks like this..
    SELECT <some fields.......>
    INTO  TABLE i_materials
          FROM  ( marc AS b
          INNER JOIN mara AS a ON amatnr = bmatnr
          INNER JOIN mvke AS c ON cmatnr = amatnr
          INNER JOIN ampl AS g ON gbmatn = amatnr
          LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
                                   AND dbwkey = bwerks )
      WHERE a~matnr  IN s_matnr AND .................
    Else
    SELECT <some fields.......>
    INTO  TABLE i_materials
          FROM  ( marc AS b
          INNER JOIN mara AS a ON amatnr = bmatnr
          INNER JOIN mvke AS c ON cmatnr = amatnr
          INNER JOIN ampl AS g ON gbmatn = amatnr
          LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
                                   AND dbwkey = bwerks )
       FOR ALL ENTRIES IN i_mara
         WHERE a~matnr = i_mara-matnr AND ............

  • I got a flashing folder with a question mark. I got a new hard drive and upgraded to 4 gigs and can't open anything or reload the operating system? Help?

    I got a flashing folder with a question mark. I got a new hard drive and upgraded to 4 gigs and can't open anything or reload the operating system? Help? FYI: I have been using boot camp with windows 7 and started getting a kernal_data_Page_error and it would reboot windows, i was trying to do a chkdsk on the next reboot, but thats when i started getting this issue. I have put in a new hard drive and went from 2 gigs to 4. I can not get the computer to do anything, even the monitor does not show anything now????

    Prep your new drive:
    Drive Preparation
    1. Boot from your OS X Installer Disc. After the installer loads select your language and click on the Continue button.  When the menu bar appears select Disk Utility from the Utilities menu.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area.  If it does not say "Verified" then the drive is failing or has failed and will need replacing.  SMART info will not be reported  on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Click on the Options button, set the partition scheme to GUID (for Intel Macs) or APM (for PPC Macs,) then click on the OK button. Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Security button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    After formatting has completed quit DU and return to the installer. Install OS X.

  • 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

  • So i have a 2011 MacBook Pro and when i turned it on this morning a flashing folder came on with a question mark in the middle of it and it keeps flashing. So i tried googling any solutions and up so far nothing has worked. Please Help ?

    I tried googling several solutions, but so far nothing seems to work. Everytime i start up my laptop i press CMND+R to make it go to the repair disk utility but instead it takes me as if i have to install lion when i had Snow Leopard 10.6.8. When i do go to the repair disk utility, on the eft hand side shows two hardrives one is Untitled and another is Hitachi, i tried downloading snow leopard 10.6.8 onto a Re-writable disc  using my windows computer. When i insterted it onto the disc drive it came out under SUPER DRIVE and everytime i double click on the CD it says something about attaching images/ I also forgot to mention that the MAC OSX 10.6.8 Update shows on the left hand side on the bottom in DMG format. I dont know what else to do, please help?

    DestroyGalaxies wrote:
    a flashing folder came on with a question mark in the middle of it
    This is the firmware telling you it can't find a bootable OS X volume.
    Usually to solve this all you do is hold the option key down on the built in keyboard while booting the computer, this enters Startup Manager and then you choose OS X to boot, then in System Preferences > Startup Disk you change it to the boot volume and it tells the firmware.
    Everytime i start up my laptop i press CMND+R to make it go to the repair disk utility but instead it takes me as if i have to install lion when i had Snow Leopard 10.6.8.
    What you have is a 10.7 or 10.8 Recovery HD from when 10.7 or 10. was on the machine previously.
    The Macintosh HD partition only was erased and 10.6 installed on it, without erasing the entire drive like what should have occured to remove the Recovery HD partition.
    So you have a mucked up machine.
    i tried downloading snow leopard 10.6.8 onto a Re-writable disc  using my windows computer.
    Well there goes your problem there, your downloading illegal copies of Snow Leopard from a untrusted location.
    10.6 is not available for download, except from pirate sites. You likely have malware or a compromised system.
    I dont know what else to do, please help?
    What you need to do is call Apple via phone, tell them the make of your machine and order the appropriate 10.6 disks, they are inexpensive now. Some machines that came with 10.6.3+ origianlly need machine specific disks, other wise pre-10.6.3 Intel Macs can use the 10.6.3 white retail disks.
    Once you have the disks, you need to backup your personal information off the computer to a external storage drive using the emergency quick copy method, then disconnect it to prevent mistakes.
    Most commonly used backup methods
    Next follow this proceedure and make sure to select the ENTIRE drive on the far left with the drive makers name and size, this will erase the entire drive, then install 10.6 from the disk
    How to erase and install Snow Leopard 10.6
    When finished setup the machine and log onto the Internet and use Software Update to get current on 10.6.8
    Don't use pirated software, it's likely been compromised in some fashion.

  • How Can We Tune the Joins with "OR" Caluse ?

    Hi
    We've identified one Query in one of Our PL/SQL Stored Procedure which is taking huge time to fetch the records. I have simulated the problem as shown below. The problem Is, How can i tune the Jions with "OR" Clause. i have tried replacing them with Exists Caluse, But the Performance was not much was expected.
    CREATE TABLE TEST
    (ID NUMBER VDATE DATE );
    BEGIN
      FOR i IN 1 .. 100000 LOOP
        INSERT INTO TEST
        VALUES
          (i, TO_DATE(TRUNC(DBMS_RANDOM.VALUE(2452641, 2452641 + 364)), 'J'));
        IF MOD(i, 1000) = 0 THEN
          COMMIT;
        END IF;
      END LOOP;
    END;
    CREATE TABLE RTEST1 ( ID NUMBER, VMONTH NUMBER );
    INSERT INTO RTEST1
    SELECT ID, TO_NUMBER(TO_CHAR(VDATE,'MM'))
    FROM TEST ;
    CREATE TABLE RTEST2 ( ID NUMBER, VMONTH NUMBER );
    INSERT INTO RTEST2
    SELECT ID, TO_NUMBER(TO_CHAR(VDATE,'MM'))
    FROM TEST;
    CREATE INDEX RTEST1_IDX2 ON RTEST1(VMONTH)
    CREATE INDEX RTEST2_IDX1 ON RTEST2(VMONTH)
    ALTER TABLE RTEST1 ADD CONSTRAINT RTEST1_PK  PRIMARY KEY (ID)
    ALTER TABLE RTEST2 ADD CONSTRAINT RTEST2_PK  PRIMARY KEY (ID)
    SELECT A.ID, B.VMONTH
    FROM RTEST1 A , RTEST2 B
    WHERE A.ID = B.ID  
    AND ( (A.ID = B.VMONTH) OR ( B.ID = A.VMONTH ) )  
    BEGIN
    DBMS_STATS.gather_table_stats(ownname => 'PHASE30DEV',tabname => 'RTEST1');  
    DBMS_STATS.gather_table_stats(ownname => 'PHASE30DEV',tabname => 'RTEST2');
    DBMS_STATS.gather_index_stats(ownname => 'PHASE30DEV',indname => 'RTEST1_IDX1');
    DBMS_STATS.gather_index_stats(ownname => 'PHASE30DEV',indname => 'RTEST2_IDX2');
    DBMS_STATS.gather_index_stats(ownname => 'PHASE30DEV',indname => 'RTEST1_IDX2');
    DBMS_STATS.gather_index_stats(ownname => 'PHASE30DEV',indname => 'RTEST2_IDX1');
    END; Pls suggest !!!!!!! How can I tune the Joins with "OR" Clause.
    Regards
    RJ

    I don't like it, but you could use a hint:
    SQL>r
      1  SELECT A.ID, B.VMONTH
      2  FROM RTEST1 A , RTEST2 B
      3  WHERE A.ID = B.ID
      4* AND ( (A.ID = B.VMONTH) OR ( B.ID = A.VMONTH ) )
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=94 Card=2 Bytes=28)
       1    0   TABLE ACCESS (BY INDEX ROWID) OF 'RTEST2' (Cost=94 Card=1 Bytes=7)
       2    1     NESTED LOOPS (Cost=94 Card=2 Bytes=28)
       3    2       TABLE ACCESS (FULL) OF 'RTEST1' (Cost=20 Card=100000 Bytes=700000)
       4    2       BITMAP CONVERSION (TO ROWIDS)
       5    4         BITMAP AND
       6    5           BITMAP CONVERSION (FROM ROWIDS)
       7    6             INDEX (RANGE SCAN) OF 'RTEST2_PK' (UNIQUE)
       8    5           BITMAP OR
       9    8             BITMAP CONVERSION (FROM ROWIDS)
      10    9               INDEX (RANGE SCAN) OF 'RTEST2_IDX1' (NON-UNIQUE)
      11    8             BITMAP CONVERSION (FROM ROWIDS)
      12   11               INDEX (RANGE SCAN) OF 'RTEST2_PK' (UNIQUE)
    Statistics
              0  recursive calls
              0  db block gets
         300332  consistent gets
              0  physical reads
              0  redo size
            252  bytes sent via SQL*Net to client
            235  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed
    SQL>SELECT /*+ ordered use_hash(b) */ A.ID, B.VMONTH
      2    FROM RTEST1 A, RTEST2 B
      3   WHERE A.ID = B.ID  AND(A.ID = B.VMONTH OR B.ID = A.VMONTH)
      4  ;
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=175 Card=2 Bytes=28)
       1    0   HASH JOIN (Cost=175 Card=2 Bytes=28)
       2    1     TABLE ACCESS (FULL) OF 'RTEST1' (Cost=20 Card=100000 Bytes=700000)
       3    1     TABLE ACCESS (FULL) OF 'RTEST2' (Cost=20 Card=100000 Bytes=700000)
    Statistics
              9  recursive calls
              0  db block gets
            256  consistent gets
            156  physical reads
              0  redo size
            252  bytes sent via SQL*Net to client
            235  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed

  • HT4718 I have nothing on my Mcintosh HD after trying to install Mavericks. I did save a recovery copy of files however this was also lost. All I now have is a file with a question mark with nothing else happening. What should I do?

    Apple recently sent a message asking me if I would like to upgrade to Mavericks which was free. I considered installing after saving a copy of my HD to a WD external drive. I proceeded with the instalation however when it was time to reboot the programme the computer displayed a message that it could not process the request due to errors with the hard drive. The computer then requested that i save a copy and the verify disk and repair disk which i followed and the computer would not repair due to an error. At which pioint I did some research and was told by the IMac to push shift when it starts to enter disk utility and repair the Mcintosh HD. I did as asked however the computer would still not install with Mavericks.
    So after many attempts of trying to start over, I was prompted to erase the Mcintosh HD and reboot using the saved copy. At this point all data was lost and all that is left on my computer is a file with a question mark with no way of restoring the HD drive. Could anyone help please?

    It sounds like your HD may have died.
    If you could answer a few questions it may help figure out what you should do next:
    What OS did you have on your computer before you tried to upgrade to mavericks?
    Did your computer originally come with installer disks?

  • Anyone help mac book screen White with a question Mark in the middle of the screen .matthew

    Can anyone help my mac book screen has gone White with a question Mark in the middle of the screen .Matthew

    Reinstall OS X without erasing the drive
    Do the following:
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install the Combo Updater for the version you prefer from support.apple.com/downloads/.

Maybe you are looking for