Equi JOINS vs SUBQUERY

May I know the difference in processing time or execution time when we use the Equi-Join and when we use Suquery in Search criteria.
Plz help, because the query (137 query) which we have written contains Subquery and fetching thousands of records, taking processing time 10 min.
We also altered the query batch with Equi-Joins and it is taking only 5 min. So can we say that Equi-Joins are much faster then Subquery.
Do Reply.
Thank in Advance
Vishal
(Database Developer)

In theory, it shouldn't matter. If you are able to figure out how to unnest subquery, the optimiser query transformation engine would likely to be able to do that that as well.

Similar Messages

  • Equi join-same output get from subquery??

    Hi,
    I written one equi-join query, same ouput can i get from sub query??.
    select e.empno,e.ename from emp e,dept d
    where e.deptno=d.deptno;
    Regards,
    Venkat.

    Really have no idea what you mean.
    If you need those d. columns, just add them to your select list.
    There's no subquery here at all.

  • Difference between JOIN and Subquery

    HI all,
    What is the difference between JOIN and Subquery?
    Regards,
    - Sri

    JOIN is combining factor or two data sources.
    Subquery is the resultant set of datasource(s) which can be joined/compared to other data source in your main query.

  • Equi Join and Outer join using outer keyword

    Hi,
    First lets take the create statment for scott schema.
    create table scott.emp_details(empno number, bonus_date date);
    Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
    Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
    Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
    Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
    Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
    commit;lets also consider the basic scott.emp and scott.dept tables
    Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
    The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
    Please suggest

    Hi,
    sri wrote:
    Hi,
    First lets take the create statment for scott schema.
    create table scott.emp_details(empno number, bonus_date date);
    Insert Into Scott.Emp_Details Values(7369, To_Date('01-jan-2013'));
    Insert Into Scott.Emp_Details Values(7499, To_Date('05-jan-2013'));
    Insert Into Scott.Emp_Details Values(7521, To_Date('10-jan-2013'));
    Insert Into Scott.Emp_Details Values(7566, To_Date('01-feb-2013'));
    Insert Into Scott.Emp_Details Values(7654, To_Date('05-feb-2013'));
    commit;
    It's best not to create your own tables in Oracle-supplied schemas, such as SCOTT. Use your own schema for your own tables.
    lets also consider the basic scott.emp and scott.dept tablesI see; you're using the standard scott,emp and scott.dept tables, plus the emp_details table you posted above.
    Now I would like to equi join emp table deptno col with dept table deptno col and left outer join emp table hiredate with emp_details bonus_date and empno col in emp_details can be joined(Equi Join) with empno col of emp table if needed .The outer join has to be placed using the keyword (left/right)outer join
    The select statement can have all the detials of emp table .The requirement may look weird but we have some such requirement.
    Please suggestThanks for posting the sample data. Don't forget to post the exact output you want from that sample data.
    Do you want something like this?
    `    EMPNO ENAME          DEPTNO DNAME          BONUS_DAT
          7369 SMITH              20 RESEARCH       01-JAN-13
          7499 ALLEN              30 SALES          05-JAN-13
          7521 WARD               30 SALES          10-JAN-13
          7566 JONES              20 RESEARCH       01-FEB-13
          7654 MARTIN             30 SALES          05-FEB-13
          7698 BLAKE              30 SALES
          7782 CLARK              10 ACCOUNTING
          7788 SCOTT              20 RESEARCH
          7839 KING               10 ACCOUNTING
          7844 TURNER             30 SALES
          7876 ADAMS              20 RESEARCH
          7900 JAMES              30 SALES
          7902 FORD               20 RESEARCH
          7934 MILLER             10 ACCOUNTING
                                  40 OPERATIONSIf so, here's one way to do it:
    SELECT       e.empno, e.ename     -- or whatever columns you want
    ,       d.deptno, d.dname     -- or whatever columns you want
    ,       ed.bonus_date
    FROM           scott.dept  d
    LEFT OUTER JOIN      scott.emp   e   ON  e.deptno     = d.deptno
    LEFT OUTER JOIN      emp_details ed      ON  ed.empno     = e.empno
    ORDER BY  e.empno
    ;

  • Creating table using joins in subquery

    can we create a table by using joins in subquery??
    like this
    create table emp as select * from employees e,departments d
    where d.department_id=e.department_id
    can we ??

    What happens when you try it?
    It worked for me. See below:
    drop table test_table;
    create table test_table as
    select e.employee_id, e.first_name || ' ' || e.last_name ename, e.email, e.salary, d.department_name
      from employees e
      join departments d
        on (e.department_id = d.department_id)
    where e.salary = 10000;
    select *
      from test_Table;
    EMPLOYEE_ID ENAME                                          EMAIL                       SALARY DEPARTMENT_NAME             
            150 Peter Tucker                                   PTUCKER                      10000 Sales                         
            156 Janette King                                   JKING                        10000 Sales                         
            169 Harrison Bloom                                 HBLOOM                       10000 Sales                         
            204 Hermann Baer                                   HBAER                        10000 Public Relations

  • Help needed on Equi join?

    I have 3 views and in that common column datatype is varchar. I have to use equi join to get the data from 3 view.
    In 3 views total records are 23668,111,3033
    when i wrote the join i am getting the output in lakhs. I don't whether the output is right or not.
    Please guide me on this.
    Waiting for valuable replies.
    Thanks and Regards
    Sridhar.

    If you're returning more rows than you expect, it means that you have 1 to many or even many to many join.
    I would re-write your query this way:
    SELECT p.facid, rxs.rxno, rxs.rxbatch,patlname,patfname,InitReview,LabelPrintedOn,packed,PlacedInTote,street1,zip,BatchDescr
    FROM Patients p
    INNER JOIN rX.dbo.rxs rxs
    ON p.facid = rxs.FacID
    INNER JOIN rX.dbo.RxBatches Batch
    ON p.facid= Batch.FacID
    WHERE p.facid in('CRH','LSRX') and Batch.batchdescr LIKE 'STAT%'
    I also suggest to add alias to every column in your query. Even if the column belongs to a particular table, adding the alias in front of it will make maintenance of this query much easier. Say, I have no idea if BatchDescr field belongs to the second table
    RxBatches or rxS, so I made a guess.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

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

  • Equi join v/s natural join

    hi
    i am using oracle 9.0.1.1.1...
    and using hr schema table employees and departments..when i use equi join on both table it return 107 ...when perform natural join it return 32 rows,,i read in books equi and natural join is same ....why both r return diffrent answer...if they r same...

    The following sample data was used:
    WITH emp as
         SELECT 'joe' AS emp, 1 AS dept_id FROM DUAL UNION ALL
         SELECT 'jill' AS emp, 1 AS dept_id FROM DUAL UNION ALL
         SELECT 'jack' AS emp, 1 AS dept_id FROM DUAL UNION ALL
         SELECT 'jane' AS emp, 2 AS dept_id FROM DUAL UNION ALL
         SELECT 'jeb' AS emp, 2 AS dept_id FROM DUAL UNION ALL
         SELECT 'jed' AS emp, 2 AS dept_id FROM DUAL UNION ALL
         SELECT 'joseph' AS emp, 3 AS dept_id FROM DUAL UNION ALL
         SELECT 'jackie' AS emp, 3 AS dept_id FROM DUAL
    dept as
         SELECT 'accounting' as dept_name, 1 as dept_id, 2 as real_dept_id FROM DUAL UNION ALL
         SELECT 'IT' as dept_name, 2 as dept_id, 4 as real_dept_id FROM DUAL UNION ALL
         SELECT 'hr' as dept_name, 3 as dept_id, 6 as real_dept_id FROM DUAL
    )NATURAL JOIN (implicitly joins on dept_id columns because of the same column name):
    SELECT emp,dept_name
    FROM emp NATURAL JOIN dept
    EMP    DEPT_NAME
    joe    accounting
    jill   accounting
    jack   accounting
    jane   IT
    jeb    IT
    jed    IT
    joseph hr
    jackie hrEQUIJOIN, you must specify the columns. In this case if you specify the same join condition the NATURAL JOIN chose you will get the same results:
    SELECT emp,dept_name
    FROM emp JOIN dept ON dept.dept_id = emp.dept_id
    EMP    DEPT_NAME
    joe    accounting
    jill   accounting
    jack   accounting
    jane   IT
    jeb    IT
    jed    IT
    joseph hr
    jackie hrHowever, if the real join column was REAL_DEPT_ID then the NATURAL JOIN cannot satisfy that condition because the column names are different. You would have to use the EQUIJOIN
    SELECT emp,dept_name
    FROM emp JOIN dept ON dept.real_dept_id = emp.dept_id
    EMP    DEPT_NAME
    jane   accounting
    jeb    accounting
    jed    accountingHope this helps!

  • Equi join

    how can we identify that when we have to use equi join and when we have to use non equi join?

    Hi,
    Use an equi-join if you want to join two tables when each table has a value that will be exactly the same as some value in the other table.
    For example, each department in scott.dept has a deptno.  Employees in scott.emp are asigned to department.  The deptno value of the department (from the scott.dept table) is also put into the deptno column of the scott.emp table.  When joining those tables by deptno, use an equi-join:
    FROM    scott.dept  d
    JOIN    scott.emp   e  ON  e.deptno  = d.deptno

  • LEFT OUTER JOIN with SubQuery

    I have two tables and I want to return all data from the first table with a piece of information from the second based on an effective date being at least a certain value. The tables I am working with contain billions of rows so I need a solution that will also scale.
    Sample tables:
    create table pp ( x number, y number);
    create table ec ( x number, y number, effdate date);
    insert into pp values (1,2);
    insert into pp values (2,3);
    insert into pp values (1,3);
    insert into ec values (1,2,sysdate);
    insert into ec values (2,3,sysdate);
    insert into ec values (1,3,sysdate+365);
    commit;
    select * from pp, ec where pp.x = ec.x(+) and pp.y=ec.y(+)
    and (effdate = ( select max(effdate) from ec ecc where ecc.y=ec.y and ecc.x = ec.x and effdate < sysdate) or effdate is null);
    The above query (and the one below) returns two rows. it does not return where the date does not meet the criteria.
    select * from pp LEFT OUTER JOIN ec ON pp.x = ec.x and pp.y=ec.y
    WHERE (effdate = ( select max(effdate) from ec ecc where ecc.y=ec.y and ecc.x = ec.x and effdate < sysdate) or effdate is null);
    This returns the three rows BUT IS VERY SLOW when run against the billion+ row table (because we cannot correlate the subquery results.)
    select * from pp LEFT OUTER JOIN (SELECT x, y, effdate
    FROM ec WHERE effDate = (SELECT MAX(EFFdate) from ec ecc where ecc.y=ec.y and ecc.x = ec.x and effdate < sysdate)) c ON c.x = pp.x and c.y = pp.y;

    It would help quite a bit to know
    1) your Oracle version
    2) your indexes and data volumes (do BOTH tables have billions of rows?)
    But here's something that may perform faster.
    ME_XE? WITH Maximizied AS
      2  (
      3     SELECT
      4        MAX(EffDate),
      5        x,
      6        y
      7     FROM ec
      8     WHERE EffDate < SYSDATE
      9     GROUP BY x, y
    10  )
    11  SELECT *
    12  FROM pp p, Maximizied m
    13  WHERE p.x = m.x (+)
    14  AND   p.y = m.y (+);
                     X                  Y MAX(EFFDAT                  X                  Y
                     2                  3 05-29-2008                  2                  3
                     1                  2 05-29-2008                  1                  2
                     1                  3
    3 rows selected.
    Elapsed: 00:00:00.03

  • Oracle Equi Join Query

    Can sombody tell me the difference betweeen Query 1 * Query 2. They give the same result. Let me know keeping performance in mind which one should be used.
    create table x (id number, name varchar2(100))
    create table y (id number, name varchar2(100))
    create table z (id number, name varchar2(100))
    insert into x values(1,'test1')
    insert into x values(2,'test2')
    insert into x values(3,'test3')
    insert into x values(4,'test4')
    insert into y values(1,'test5')
    insert into y values(3,'test6')
    insert into z values(1,'test7')
    insert into z values(4,'test8')
    QUERY1
    select x.id,y.id,z.id,x.name,y.name,z.name
    from x,y,z
    where
    x.id = y.id
    and x.id = z.id
    and (x.id =2 or x.id = 1)
    QUERY2
    select x.id,y.id,z.id,x.name,y.name,z.name
    from x
    JOIN y
    ON x.id = y.id
    JOIN z
    ON x.id = z.id
    and (x.id =2 or x.id = 1)

    Sorry i forgot the integrity constraints:
    create table x (id number, name varchar2(100))
    create table y (id number, name varchar2(100))
    create table z (id number, name varchar2(100))
    alter table x add constraint x_pk primary key(id)
    alter table y add constraint y_fk foreign key(id)
    REFERENCES X(ID)
    alter table z add constraint z_fk foreign key(id)
    REFERENCES X(ID)
    insert into x values(1,'test1')
    insert into x values(2,'test2')
    insert into x values(3,'test3')
    insert into x values(4,'test4')
    insert into y values(1,'test5')
    insert into y values(3,'test6')
    insert into z values(1,'test7')
    insert into z values(4,'test8')
    select x.id,y.id,z.id,x.name,y.name,z.name
    from x,y,z
    where
    x.id = y.id
    and x.id = z.id
    and (x.id =2 or x.id = 1)
    select x.id,y.id,z.id,x.name,y.name,z.name
    from x
    JOIN y
    ON x.id = y.id
    JOIN z
    ON x.id = z.id
    and (x.id =2 or x.id = 1)

  • Complex Inner Join and subquery on outer where clause on inner join?

    The DDL for this post was too big and I had to put on my website:
    http://www.harbortownsolutions.com/DDLForDORTable.txt
    My goal is to create a report of sales data for 116 stores containing daily sales and guest count to last years. My challenge is I'm pulling data from the same table but with different dates to get data from last year and Week to date data from last year.
    Dates used for reports are:
    SalesDate = 6/4/2009
    SalesDateForLastYear = 6/5/2008
    SalesDateBeginningOfWeek = 6/1/2009
    SalesDateBginningOFWeekLastYear = 6/2/2008
    PSEUDOQUERYS:
    ---======= DOLLAR VARIANCE = You Said you have $100 worth of meat(inventory) but you only have $50 worth of meat
    SELECT
        BUSI_DATE as BusinessDate,
        ORACLE_KEY as StoreID,
        FIELD1  as Sales,
        FIELD2  as GuestCount,
        FIELD3  as DollarVariance,
        FIELD4  as Cars
    FROM MYDAILYTOTALS
    WHERE Busi_date = SalesDate
       AND ORACLE_KEY IN (SELECT StoreID From MyStores);
    -======= ONLY Guest count and Sales are needed in comparisons against last year   
    ---======    Last YEar dates = corresponding dates for this year ie Tuesday of this
    week matched to Tuesday of last year (except for leap year)
    SELECT
        ORACLE_KEY as StoreID
        FIELD1  as SalesLastYear
        FIELD2  as GuestCountLastYear  
    FROM MYDAILYTOTALS
    WHERE Busi_date = SalesDateForLastYear
       AND ORACLE_KEY IN (SELECT StoreID From MyStores);
    SELECT
        ORACLE_KEY as StoreID
        SUM(FIELD1)  as WeekToDateSales
        SUM(FIELD2)  as WeekToDateGuestCount 
    FROM MYDAILYTOTALS
    WHERE Busi_date BETWEEN SalesDateBeginningOfWeek and SalesDate
       AND ORACLE_KEY IN (SELECT StoreID From MyStores)
    GROUP BY ORACLE_KEY
       --======= 
    SELECT
        ORACLE_KEY as StoreID
        SUM(FIELD1)  as WeekToDateSalesLastYear
        SUM(FIELD2)  as WeekToDateGuestCountLastYear 
    FROM MYDAILYTOTALS
    WHERE Busi_date BETWEEN SalesDateBeginningOfWeekLastYear and SalesDateLastYear
       AND ORACLE_KEY IN (SELECT StoreID From MyStores)
    GROUP BY ORACLE_KEY   Question: Since they all use the same store nbrs, do I need to specify on each query? CAn't i jsut specify once on outer query Where clause?
    Also How would I integrate the following script from HOEK:
    See How do I set 1 field based on another field's value
    It gets a record for each store of the 116 stores from inventory database. There were 2 situations that were addressed by Hoeks code:
    For each of the 116 stores in store table, there must be 1 and only
    1 inventory record to match the MyStoreTotals record. However, sometimes there will be no inventory record.
    and sometimes there will be 2 (in a case where a manager updates database
    after daily processing) records. if so, the record with Is_posted = 1
    is the one that should be included in query. The following accomplishes this:
    -- chr(39) is single quote
    Select StoreId,
             DollarVariance
      from   (select store.storeid,
                       case
                              when inv.storeid is null then 'None'
                              when inv.is_posted = 0 then 'NP'
                              else chr(39)||inv.total_dol_var||chr(39)
                        end as DollarVariance,
                        row_number() over (partition by store.storeid order by inv.is_posted desc) rn 
                   from  myInven inv
                   right outer join mystores  store
                                  on store.storeid = inv.fk_str_main_id
                                  and inv.busi_date = to_date(SalesDate, 'dd-mon-yyyy'))
          where rn = 1;      Do I put this query on the where clause of the outer query of do I put it on a JOIN clause?

    Here is Part 2: The Insert for totals table
    ---=== POPULATE TOTALS
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',21,3163.79,189.83,0,-190.7);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',22,2747.25,255.37,0,-235.95);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',23,4182.74,388.74,0,-248.47);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',24,4551.5,423.05,0,-467.46);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',25,2785.13,258.8,0,-199.85);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',27,3409.31,317,0,-175.18);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',28,3808.61,228.6,0,-233.04);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',29,3416.97,239.35,0,-110.77);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',30,2133.4,128.13,0,-178.37);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',31,2261.27,210.14,0,-272.39);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',32,2258.18,135.6,0,-83.01);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',33,3908.26,312.71,0,-121.41);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',34,3035.45,273.38,0,-97.8);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',35,3088.44,185.5,0,-123.56);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',36,4255.4,395.48,0,-206.16);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',37,6331.13,380.01,0,-505.47);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',38,3552.78,319.94,0,-168.33);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',39,2991.44,277.96,0,-228.98);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',40,0,0,0,0);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',41,3825.03,355.49,0,-204.93);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',42,3843.16,357.16,0,-237.5);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',43,2981.78,179,0,-45.97);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',61,4504.6,270.32,0,-362.49);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',62,4034.46,242.1,0,-260.95);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',64,1811.58,168.39,0,-108.78);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',65,2271.46,211.04,0,-117.32);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',66,2336.32,217.02,0,-95.28);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',67,4208.13,410.39,0,-197.3);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',68,2803.55,273.31,0,-154.11);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',69,1702.81,153.46,0,-98.58);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',70,4098.3,399.51,0,-208.42);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',71,1952.1,190.26,0,-59.51);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',72,4716.07,283.07,0,-428.18);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',73,2897.56,269.43,0,-329.79);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',74,0,0,0,0);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',75,3438.59,319.84,0,-344.96);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',76,3016.7,280.67,0,-106.39);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',78,4228.31,253.73,0,-249.33);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',81,4152.43,249.33,0,-135.87);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',82,3772.42,350.69,0,-174.02);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',83,2594.06,241.02,0,-196.18);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',101,3868.21,232.21,0,-360.36);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',141,2246.55,134.92,0,-100.97);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',181,2357.75,219.07,0,-205.8);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',202,2724.47,163.47,0,-107.54);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',203,3225.11,193.67,0,-143.19);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',204,2641.28,158.55,0,-131.84);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',205,4644.56,278.72,0,-260.48);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',206,3859.62,231.76,0,-203.47);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',221,3647.04,355.53,0,-186.82);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',222,2446.59,227.42,0,-172.67);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',223,3439.52,319.61,0,-264.23);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',224,3121.7,290.07,0,-284.98);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',241,2858.38,228.81,0,-279.91);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',243,4983.38,299.22,0,-370.89);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',244,2970.69,178.37,0,-189.97);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',245,5829.93,349.97,0,-215.5);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',246,4344.78,260.79,0,-120.38);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',247,4154.77,249.52,0,-175.08);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',248,4875.21,292.58,0,-296.04);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',249,4041.39,242.6,0,-99.91);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',250,2933.45,176.04,0,-208.56);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',251,5448.82,327.13,0,-358.71);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',252,2429.18,224.88,0,-136.03);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',253,2884.63,173.14,0,-83.95);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',254,3708.4,222.64,0,-318.75);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',255,3722.19,346.22,0,-204.4);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',256,3834.23,230.16,0,-245.91);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',257,3456.4,321.22,0,-259.7);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',258,3018.22,181.16,0,-146.83);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',259,2807.65,260.97,0,-241.13);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',260,3424.99,318.21,0,-229.06);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',262,3782.55,351.66,0,-174.42);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',263,2570.84,239.08,0,-184.58);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',264,3904.8,234.22,0,-235.03);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',265,2853.7,286.29,0,-253.16);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',266,3246.72,194.76,0,-237.36);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',267,3712.25,417.97,0,-257.5);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',268,4141.22,248.53,0,-68.98);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',269,3693.64,221.77,0,-228.45);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',271,3775.03,226.8,0,-213.14);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',272,2870.1,172.27,0,-514.23);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',273,3132.8,188.22,0,-148.05);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',274,2454.86,147.31,0,-142.1);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',276,3627.72,337.17,0,-232.38);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',277,3118.79,187.21,0,-152.68);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',278,3360.09,302.7,0,-220.63);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',279,2478.11,230.44,0,-192.49);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',280,3252.54,302.38,0,-213.72);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',281,3654.62,219.44,0,-164.95);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',282,3159.75,189.72,0,-168.68);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',285,2839.63,241.67,0,-238.7);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',286,3468.01,322.29,0,-186.25);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',287,3546.42,329.74,0,-160.14);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',289,2331.57,174.44,0,-293.47);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',290,1702.25,131.62,0,-101.72);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',291,3969.8,369.02,0,-253.26);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',292,2265.99,210.52,0,-182.05);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',293,3234.72,258.74,0,-137.08);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',294,3932.19,354.24,0,-201.15);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',295,3754.2,225.46,0,-307.99);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',296,3885.37,235.24,0,-293.24);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',298,2479.43,148.86,0,-207.68);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',321,3542.26,212.71,0,-206.25);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',362,1540.87,142.53,0,-101.3);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',363,2798.87,314.66,0,-356.52);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',364,2658.94,212.7,0,-159.29);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',365,0,0,0,0);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',381,3155.66,189.48,0,-229.18);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',441,1389.79,98.92,0,-77.94);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',461,1874.39,149.82,0,-298.2);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',462,2539.64,161.32,0,-206.73);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',501,3861.36,357.29,0,-286.17);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',521,3449.41,318.93,0,-182.83);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',522,2938.99,176.51,0,-149.65);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',523,4352.54,261.29,0,-333.7);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',524,4163.36,385.54,0,-352.01);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',544,2481.37,260.53,0,-29.9);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',564,2344.38,211.07,0,-153.02);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-08',624,3136.78,188.29,0,-199.51);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',21,3250.89,195.13,0,-161.39);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',22,2595.78,241.23,0,-159.05);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',23,4533.49,421.43,0,-348.07);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',24,5337.24,496.17,0,-475.37);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',25,3328.26,309.42,0,-172.65);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',27,3680.53,342.16,0,-159.81);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',28,3850.95,231.21,0,-343.33);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',29,3470.75,243.07,0,-112.19);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',30,2799.58,168.14,0,-321.17);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',31,2241.6,208.23,0,-249.08);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',32,2744.05,164.74,0,-138.96);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',33,3987.38,319.11,0,-111.6);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',34,2996.06,269.94,0,-135.31);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',35,3502.73,210.32,0,-100.55);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',36,3553.27,330.15,0,-176.07);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',37,6387.03,383.52,0,-497.73);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',38,3295.64,296.86,0,-183.05);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',39,2891.77,268.67,0,-79.79);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',40,0,0,0,0);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',41,3806.24,354.67,0,-183.84);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',42,3572.47,332.13,0,-176.78);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',43,3231.48,193.91,0,-101.76);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',61,4812.72,289.03,0,-309.85);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',62,4245.8,254.83,0,-241.36);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',64,1925.79,179.05,0,-81.31);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',65,2350.08,218.44,0,-49.03);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',66,2440.74,226.71,0,-103.36);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',67,4154.7,405.04,0,-142.79);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',68,3177.54,309.78,0,-203.25);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',69,1602.51,144.48,0,-89.2);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',70,4332.09,422.2,0,-279.47);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',71,2266.95,220.94,0,-147.58);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',72,5270.73,316.57,0,-636.12);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',73,2982.05,277.08,0,-292.33);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',74,0,0,0,0);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',75,3708.11,344.64,0,-537.87);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',76,2984.98,277.59,0,-163.33);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',78,4308.12,258.69,0,-242.15);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',81,4122.56,247.58,0,-201.33);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',82,3816.69,354.86,0,-219.83);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',83,2587.89,240.53,0,-225.54);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',101,4369.67,262.3,0,-206.67);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',141,2603.25,156.3,0,-101.35);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',181,2147.47,199.55,0,-216.75);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',202,2622.75,157.5,0,-135.47);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',203,3574.63,214.73,0,-219.38);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',204,2906.92,174.56,0,-110.08);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',205,4895.05,293.87,0,-277.18);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',206,3520.21,211.2,0,-269.1);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',221,4079.8,397.83,0,-135.79);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',222,2420.63,225.04,0,-218.93);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',223,3071.77,285.46,0,-204.44);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',224,3162.39,293.88,0,-364.17);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',241,3207.99,256.68,0,-150.69);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',243,5195.78,311.98,0,-257.23);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',244,3297.07,198.05,0,-174.03);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',245,5968.82,358.41,0,-319.01);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',246,4200.59,252.23,0,-158.47);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',247,4070,244.44,0,-192.64);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',248,4968.23,298.1,0,-230.1);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',249,4693.38,281.83,0,-51.24);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',250,3101.72,186.19,0,-65.67);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',251,5772.54,346.49,0,-370.65);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',252,2616.47,242.24,0,-313.94);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',253,3471.22,208.33,0,-125.65);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',254,3878.21,232.87,0,-148.1);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',255,3863.12,359.29,0,-259.09);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',256,3710.4,222.76,0,-158.92);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',257,2998.68,278.72,0,-209.98);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',258,3589.82,215.49,0,-146.1);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',259,2767.48,257.21,0,-196.7);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',260,2973.28,276.2,0,-199.43);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',262,3859.64,358.89,0,-400.09);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',263,2812.9,261.43,0,-180.02);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',264,3916.29,234.97,0,-129.04);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',265,2756.12,276.52,0,-100.22);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',266,3164.38,190.06,0,-166.11);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',267,3510.19,395.32,0,-419.08);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',268,4404.09,264.47,0,-119.09);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',269,3719.31,223.16,0,-233.2);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',271,4072.41,244.37,0,-337.97);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',272,3547.26,212.98,0,-242.38);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',273,3055.74,183.41,0,-250.05);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',274,2494.52,149.72,0,-118.34);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',276,3547.39,329.69,0,-254.4);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',277,2904.89,174.45,0,-169.73);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',278,3437.7,309.83,0,-221.15);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',279,3142.29,292.08,0,-247.97);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',280,3470.57,322.59,0,-286.45);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',281,4075.15,244.63,0,-313.42);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',282,2873,172.52,0,-150.44);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',285,2951.56,251.12,0,-294.04);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',286,3803.64,353.56,0,-244.53);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',287,3402.96,316.4,0,-164.22);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',289,2514.92,188.12,0,-238.77);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',290,1797.42,138.89,0,-196.18);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',291,3904.15,362.83,0,-246.27);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',292,2414.91,224.34,0,-109.66);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',293,3336.49,266.85,0,-232.16);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',294,3761.44,338.74,0,-179.55);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',295,4363.6,262.12,0,-319.81);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',296,4274.18,258.43,0,-222.11);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',298,2823.18,169.51,0,-315.66);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',321,4000.01,240.05,0,-191.67);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',362,1944.95,179.72,0,-191.07);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',363,3171.3,356.66,0,-363.11);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',364,3057.67,244.75,0,-124.49);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',365,0,0,0,0);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',381,3140.8,188.58,0,-251.87);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',441,1507.47,107.24,0,-62.57);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',461,1609.21,128.6,0,-289.64);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',462,2660.68,168.81,0,-253.25);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',501,4140.65,383.21,0,-525.13);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',521,3801.87,352.02,0,-325.62);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',522,3456.49,207.58,0,-282.41);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',523,4413.29,264.6,0,-417.35);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',524,4502.73,416.91,0,-429.19);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',544,2800.89,294.13,0,-31.98);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',564,2632.22,237.14,0,-174.72);
    INSERT INTO MYDAILYTOTALS VALUES('03-JUN-08',624,3006.17,180.49,0,-186.61);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',21,3313.37,198.82,501.41,148.71);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',32,2233.4,134.06,529.18,81.52);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',39,3151.53,292.94,445.76,200.74);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',43,3260.15,195.77,708.43,138.56);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',66,2968.89,275.97,541.77,329.89);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',69,2227.11,200.54,378.5,62.78);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',73,2596.94,241.55,353.28,62.28);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',101,4263.98,255.93,555.08,339.94);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',141,2326.62,139.65,514.13,18.35);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',202,2663.65,159.94,650.3,98.32);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',206,3862.53,231.85,700.72,135.09);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',221,3458,337.07,537.24,111.94);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',223,3244.05,301.4,504.12,78.03);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',224,3271.02,304.12,488.82,142.74);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',243,4582.04,275.73,757.99,173.21);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',244,3075.06,184.7,559.75,254.56);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',245,5770.79,346.51,745.04,232.29);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',247,4445.29,266.95,707.99,148.44);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',250,2993.46,179.71,716.03,77.52);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',254,3439.15,206.53,455.68,103.27);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',258,3199.55,192.22,656.15,380.93);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',262,3863.19,359.27,530.18,57.15);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',264,4014.15,241.09,715.7,210.46);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',267,3508.58,394.9,622.73,109.92);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',271,4334.5,260.16,607.84,322.44);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',272,3402.47,204.25,504.9,230.47);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',273,3260.08,195.81,620.68,203.57);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',282,3182.51,191.16,557.39,177.95);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',292,2103.39,195.46,366.92,95.33);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',298,2997.51,179.87,452.71,210.64);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',362,1614.2,149.22,329.87,141.86);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',363,3058.98,344.1,523.53,259.03);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',523,3776.49,226.8,533.46,376.94);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',524,4720.08,437.05,554.55,320.96);
    INSERT INTO MYDAILYTOTALS VALUES('01-JUN-09',564,2725.49,245.4,419.73,134.96);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',22,2482.4,230.46,1126.91,42.33);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',23,4907.83,456.19,1254.74,305.28);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',27,3170.7,294.64,990.07,74.02);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',34,2660.45,239.48,1046.41,64.37);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',43,3459.94,207.57,1349.89,114.96);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',62,4515.62,271.13,1234.8,125.26);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',65,2196.06,204.05,1010.08,60.71);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',66,2558.77,237.84,1031.84,76.4);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',68,2677.87,261.12,950.73,184.17);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',69,2165.68,195.01,786.06,62.33);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',78,4562.37,274.06,1386.15,135.12);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',141,2690.6,161.65,1118.96,36.43);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',181,2321.7,215.62,827.14,50.56);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',244,3312.27,198.84,1099.22,235.38);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',251,6012.15,360.89,1786.03,489.65);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',252,1823.33,164.16,702.65,78.91);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',260,3030.32,281.47,958.58,90.78);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',262,4198.03,390.37,1111.2,57.21);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',263,2463.36,229.01,1010.05,39.46);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',271,4571.16,274.35,1256.94,162.23);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',276,3244.67,301.41,926.42,70.05);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',277,3650.92,219.3,1225.24,184.51);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',281,3915.25,235.15,1364.07,207.56);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',282,3207.09,192.59,1279.52,116.07);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',289,2509.67,187.63,1156.46,129.59);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',290,1840.89,133.03,885.45,166.21);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',291,3860.49,358.79,1157.38,86.91);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',295,3989.96,239.65,1258.06,239.39);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',298,2748.82,165.08,979.23,290.44);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',321,3626.59,217.84,1547.6,186.81);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',381,3030.78,181.96,977.68,246.34);
    INSERT INTO MYDAILYTOTALS VALUES('02-JUN-09',521,3349.57,310.04,1184.6,87.48);

  • Performance : join X subquery

    Hi folks,
    I have this view, developped by someone else, that have 8 selects concatenated with UNION ALL and each of these select makes a 7 tables joins.
    this view takes 2hours to run, and table sizes are :
    TABLE_NAME | SIZE(BYTES) | QTT_ROWS | SIZE/QTT_ROWS
    ------------------------------ | ----------- ---------- -------------
    CC_LANCAMENTO | 278672 | 3076347 | .09058536
    BC_PESSOA | 9880 | 31614 | .31251977
    CC_CC | 3520 | 12238 | .287628697
    CC_CONTA_GARANTIDA | 240 | 263 | .912547529
    CC_HISTORICO | 80 | 472 | .169491525
    CC_CONFIGURACAO | 16 | 1 | 16
    CC_TIPO_CC | 16 | 45 | .355555556
    Didn't SQL joins make cartesian product of joined tables and only after that extract rows that are needed?
    Instead of using all these joins, if I change some of them for subqueries, would I have a boost on performance?
    Tables have indexes and on plan I could see that in many cases they are been used. None of these tables are partitioned
    Thank you.

    I'll agree with Scott that I would generally prefer joins, but that's more of a readability issue. Particularly at the introductory level, it's hard enough to learn how to think about sets with straight joins. I've found that adding subqueries tends to muddy the waters further.
    My rule of thumb is to write the query the way it makes sense to you and the way it makes sense to others. 90+% of the time, Oracle is going to be smart enough to do the right thing, merge the subqueries, and execute the statement as if you had written the joins. If a query doesn't perform acceptably, tune it, but starting out trying to write the most efficient statement possible tends to be a productivity killer. I'd much rather have 20 queries that are easy to understand and maintain and know that I'll have to tune 1 query that confuses Oracle than to try to figure out the fastest possible way to write a query and end up with half as much code written for an imperceptible (to the user) performance gain.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Join or Subquery (In terms of performance)

    Hi All,
    Could anyone please help me to find the best performing sql shown below.
    Both SQL are having same elapsed time.
    Oracle Version 10.2.0.4
    Thanks.
    Edited by: Yasu on Nov 26, 2010 9:46 PM
    Added elapsed time information.
    Edited by: Yasu on Nov 27, 2010 10:20 AM
    Removed sensitive data

    Yasu wrote:
    We are in process of injecting new module to existing application, hence i think we can go for EXISTS, as we are not rewriting any SQL.
    Also, does it affects in any way about estimated rows in EXISTS case which are high about 19103 rows. I noticed that cardinality problem prior to posting my earlier response, but failed to mention it. The cardinality estimate problem, while it did not cause a problem with your relatively simple SQL statement, it could cause changes in the join order if the cardinality estimate problem exists in other queries.
    One more doubt.
    Why Index fast full scan is occurring instead of index range scan for LIKE operator.
    | Id  | Operation                           | Name               | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   1 |  NESTED LOOPS SEMI                  |                    |      1 |    684 |     64 |00:00:00.02 |   17148 |
    |*  2 |   INDEX FAST FULL SCAN              | PK_ORG_ALIAS_NAMES |      1 |    684 |    180 |00:00:01.29 |   16713 |
    |*  3 |   TABLE ACCESS BY GLOBAL INDEX ROWID| ORGANIZATIONS      |    170 |  19103 |     59 |00:00:00.01 |     435 |
    |*  4 |    INDEX UNIQUE SCAN                | PK_ORGANIZATIONS   |    170 |      1 |    170 |00:00:00.01 |     346 |
    Predicate Information (identified by operation id):
    2 - filter((LOWER("ORG_ALIAS_NAME") LIKE 'technology%' AND
    "F_GETFIRSTWORD"("ORG_ALIAS_NAME")='TECHNOLOGY'))
    3 - filter((COALESCE("M"."ORG_COUNTRY_OF_DOMICILE","M"."ORG_COUNTRY_OF_INCORPORATION")='US' AND
    "ORG_DATA_PROVIDER"<100))
    4 - access("M"."ORGID"="AN"."ORGID")
    DDL for index PK_ORG_ALIAS_NAMES:
    CREATE UNIQUE INDEX "PK_ORG_ALIAS_NAMES" ON "OA"."ORG_ALIAS_NAMES" ("ORGID", "ORG_ALIAS_NAME", "ORG_ALIAS_EFF_FROM_DATE")
    A range scan is not possible for the index for a couple of reasons:
    1. Based on the supplied index definition, the ORG_ALIAS_NAME column is not the leading (first) column in the index definition. So, at best an index skip scan might happen, rather than an index range scan.
    2. The LOWER() function is applied to the ORG_ALIAS_NAME indexed column.
    To see an index range scan you would likely need a function based index constructd like this:
    CREATE UNIQUE INDEX PK_ORG_ALIAS_NAMES ON OA.ORG_ALIAS_NAMES (LOWER(ORG_ALIAS_NAME), ORGID, ORG_ALIAS_EFF_FROM_DATE)However, changing the index definition as shown above might have a significant negative performance impact on other queries that are currently using the PK_ORG_ALIAS_NAMES index.
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • Complex Join in RPD with Subquery

    Hi Experts,
    We have a complex requirement in our RPD Development which needs to use a subquery in the complex join in Physical layer. Here are the tables:
    Fact A
    DIM B
    Join is A.case_no = B.case_no
       and ( a.active_date between b.start_date and b.end_date or
                 (a.active_date < b.start_date and
                  b.start_date = (select min(b2.start_date)
                                              from DIM B2
                                             where b.case_no = b2.case_no
                                             group by b2.case_no
    Is there a way other than creating opaque view or making ETL changes to having the min(start_date) as part of the table ?
    Appreciate your inputs and responses.
    Thanks
    VK

    you got 2 tables or 3?
    I see 3 tables A, B and B2
    you need to join B with B2 time being just ignore min value since its equi join you get matching only
    and then B with A
    in bmm map B2 to B

Maybe you are looking for

  • How can I get all of my graphics to import from FrameMaker?

    I am evaluating Robohelp HTML version 9, which I'm considering using for single-sourcing FrameMaker 7.1 files. I imported my FrameMaker files, and only 2 out of 75 graphics were imported. The results window shows that all FM files were imported succe

  • MIGO in 3rd party process

    Hello Experts, In a dropshipment scenario, the Supplier will deliver the goods to the customer directly. Then the seller does a MIRO for the invoice received from the supplier. Then the seller does a MIGO goods receipt and then Goods Issue before Bil

  • Service '?' unknown

    Hi, we are migrating from EP620 to EP640 and having trouble to get the MSS running. We transported the system-landscape-settings to the new portal, but now we get an error when displaying the mss-iViews: Connect to SAP gateway failed Connect_PM  TYPE

  • Error in Forms 10G isuite

    OS windows 2003 Forms 10G isuite when I am trying to run the form getting this error java.lang.classNotFoundException:oracle.forms.engine.Main

  • Is it possible to use Apple TV to display what I am viewing or listining to on my Macbook Pro?

    Morning folks- Curious if streaming music from any other player other than iTunes is possible? I listen to a ton of www.panicstream.com which features 90+% of all Widespread Panic shows going back to the mid 80's......as well as, recorded live stream