Running Total Query need help

Hi all,
i have solution i got earlier form this forum.
CREATE TABLE LHEADER
(HDT DATE,
HSR NUMBER,
HCODE VARCHAR2(6),
HAMOUNT NUMBER);
INSERT INTO LHEADER VALUES (TO_DATE('01012009','DD/MM/YYYY'),1,101,5000);
INSERT INTO LHEADER VALUES (TO_DATE('01022009','DD/MM/YYYY'),2,102,3000);
INSERT INTO LHEADER VALUES (TO_DATE('01012009','DD/MM/YYYY'),3,103,6000);
CREATE TABLE DDETAIL
(DDT DATE,
DHSR NUMBER,
DHCODE VARCHAR2(6),
DAMOUNT NUMBER,
D1 NUMBER,
D2 NUMBER,
D3 NUMBER);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),1,101,1500,NULL,NULL,10);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),1,101,NULL,20,15,20);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),1,101,NULL,20,12,20);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),1,101,NULL,20,16,20);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),1,101,NULL,20,20,20);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),2,102,2000,15,NULL,15);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),2,102,NULL,12,10,15);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),2,102,NULL,12,15,8);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),2,102,NULL,12,12,15);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),3,103,3000,NULL,30,25);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),3,103,NULL,30,20,25);
SELECT       ddt
,       dhsr
,       dhcode
,       NVL ( CASE
               WHEN  d1 + d2 + d3  IS NULL
               THEN  LAG (run_tot) OVER ( PARTITION BY  dhcode
                                             ,                dhsr
                                                       ORDER BY       ddt
          END
           , amount
           )          AS amount
,       d1
,       d2
,       d3
,       run_tot
FROM       (
     SELECT     d.ddt
     ,     d.dhsr
     ,     d.dhcode
     ,     NVL ( d.damount
                      , h.hamount
                  )               AS amount
     ,     d.d1
     ,     d.d2
     ,     d.d3
     ,     h.hamount - CASE
                       WHEN  d1 + d2 + d3     IS NULL
                    THEN  NULL
                    ELSE  SUM ( d.d1
                                     + d.d2
                               + d.d3
                               ) OVER ( PARTITION BY  d.dhcode
                                     ,                d.dhsr
                                             ORDER BY      d.ddt
                      END          AS run_tot
     FROM     ddetail         d
     ,     lheader         h     where     d.dhcode     = h.hcode
                        AND     d.dhsr          = h.hsr
ORDER BY  ddt
,            dhcode
,       d1 + d2 + d3     NULLS FIRST
DDT                 DHSR DHCODE        AMOUNT            D1            D2            D3       RUN_TOT
31/01/2009         1.000 101         1500.000                                    10.000
31/01/2009         1.000 101         5000.000        20.000        15.000        20.000      4945.000
31/01/2009         3.000 103         6000.000        30.000        20.000        25.000      5925.000
28/02/2009         1.000 101         5000.000        20.000        12.000        20.000      4893.000
28/02/2009         2.000 102         2000.000        15.000                      15.000
28/02/2009         2.000 102         3000.000        12.000        10.000        15.000      2963.000
28/02/2009         3.000 103         6000.000        30.000        20.000        25.000      5850.000
31/03/2009         1.000 101         5000.000        20.000        16.000        20.000      4837.000
31/03/2009         2.000 102         3000.000        12.000        15.000         8.000      2928.000
31/03/2009         3.000 103         6000.000        30.000        20.000        25.000      5775.000
30/04/2009         1.000 101         5000.000        20.000        20.000        20.000      4777.000
30/04/2009         2.000 102         3000.000        12.000        12.000        15.000      2889.000
30/04/2009         3.000 103         5775.000                      30.000        25.000
30/04/2009         3.000 103         6000.000        30.000        20.000        25.000      5700.000
14 rows selected.i want to the output to be like this now;
the query should SUM d1,d2 & d3 where RUN_TOT is NULL.
Rows with Null RUN_TOT should not be shown.
DDT                 DHSR DHCODE        AMOUNT            D1            D2            D3       RUN_TOT
31/01/2009         1.000 101         5000.000        20.000        15.000      *30.000*      4945.000
31/01/2009         3.000 103         6000.000        30.000        20.000        25.000      5925.000
28/02/2009         1.000 101         5000.000        20.000        12.000        20.000      4893.000
28/02/2009         2.000 102         3000.000      *27.000*        10.000        *30.000*      2963.000
28/02/2009         3.000 103         6000.000        30.000        20.000        25.000      5850.000
31/03/2009         1.000 101         5000.000        20.000        16.000        20.000      4837.000
31/03/2009         2.000 102         3000.000        12.000        15.000         8.000      2928.000
31/03/2009         3.000 103         6000.000        30.000        20.000        25.000      5775.000
30/04/2009         1.000 101         5000.000        20.000        20.000        20.000      4777.000
30/04/2009         2.000 102         3000.000        12.000        12.000        15.000      2889.000
30/04/2009         3.000 103         6000.000        30.000        *50.000      50.000*      5700.000
14 rows selected.

Hello Mr. Frank..
I designed a report based on your solution, but when executed with the actual data, with what the user have entered,
the report didn't returned the expected result. Yes, your logic with the earlier data provided by me was correct.
but now the data has appeared in different manner.
i tried to modify your query but didn't exactly succeed.
for this data;
CREATE TABLE LHEADER
(HDT DATE,
HSR NUMBER,
HCODE VARCHAR2(6),
HAMOUNT NUMBER);
INSERT INTO LHEADER VALUES (TO_DATE('10/03/2010','DD/MM/YYYY'),12,1392,48571.1);
INSERT INTO LHEADER VALUES (TO_DATE('16/03/2010','DD/MM/YYYY'),14,1526,40732);
INSERT INTO LHEADER VALUES (TO_DATE('08/01/2010','DD/MM/YYYY'),9,1835,31600);
CREATE TABLE DDETAIL
(DDT DATE,
DHSR NUMBER,
DHCODE VARCHAR2(6),
DAMOUNT NUMBER,
D1 NUMBER,
D2 NUMBER,
D3 NUMBER);
INSERT INTO DDETAIL VALUES (TO_DATE('01/10/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,217.434);
INSERT INTO DDETAIL VALUES (TO_DATE('01/11/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,210.420);
INSERT INTO DDETAIL VALUES (TO_DATE('01/09/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,210.420);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),12,1392,2470,NULL,0,2.335);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),12,1392,39573,NULL,13.851,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),12,1392,39573,NULL,13.851,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),12,1392,39573,NULL,13.850,209.466);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),12,1392,4489.7,NULL,5.836,23.765);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),12,1392,4489.7,NULL,2.918,26.311);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),12,1392,39573,0,13.855,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2008','DD/MM/YYYY'),14,1526,11620,NULL,0,50.046);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,64.642);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,58.387);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,64.642);
INSERT INTO DDETAIL VALUES (TO_DATE('01/04/2009','DD/MM/YYYY'),14,1526,19220,NULL,6.726,103.472);
INSERT INTO DDETAIL VALUES (TO_DATE('01/05/2009','DD/MM/YYYY'),14,1526,19220,NULL,6.726,106.921);
INSERT INTO DDETAIL VALUES (TO_DATE('01/05/2009','DD/MM/YYYY'),14,1526,7600,NULL,NULL,17.73);
INSERT INTO DDETAIL VALUES (TO_DATE('01/06/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.386,144.387);
INSERT INTO DDETAIL VALUES (TO_DATE('01/07/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.386,149.200);
INSERT INTO DDETAIL VALUES (TO_DATE('01/08/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,48.129);
INSERT INTO DDETAIL VALUES (TO_DATE('01/08/2009','DD/MM/YYYY'),14,1526,26820,NULL,NULL,106.472);
INSERT INTO DDETAIL VALUES (TO_DATE('01/09/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,152.102);
INSERT INTO DDETAIL VALUES (TO_DATE('01/10/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,157.173);
INSERT INTO DDETAIL VALUES (TO_DATE('01/11/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,152.102);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,157.173);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),14,1526,5700,NULL,NULL,8.620);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),14,1526,32520,NULL,11.382,190.576);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),14,1526,32520,NULL,11.382,172.133);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),14,1526,37745,NULL,13.21,221.196);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),14,1526,5225,NULL,NULL,4.939);
INSERT INTO DDETAIL VALUES (TO_DATE('04/01/2010','DD/MM/YYYY'),9,1835,31600,131.667,11.06,185.185);
INSERT INTO DDETAIL VALUES (TO_DATE('05/02/2010','DD/MM/YYYY'),9,1835,31468.333,131.667,11.014,166.567);
INSERT INTO DDETAIL VALUES (TO_DATE('08/03/2010','DD/MM/YYYY'),9,1835,31336.666,131.667,10.968,183.641);
INSERT INTO DDETAIL VALUES (TO_DATE('10/04/2010','DD/MM/YYYY'),9,1835,31204.999,131.667,10.922,176.971);
i modified your query like this;
SELECT   ddt
,   dhsr
,   dhcode
,   amount
,   d1
,   d2
,   d3
,   run_tot
FROM   (
  SELECT   ddt
  ,   dhsr
  ,   dhcode
  ,   NVL ( CASE
     WHEN  NVL(d1 + d2 + d3,0) = 0
     THEN  LAG (run_tot) OVER ( PARTITION BY  dhcode,to_char(ddt,'yyyymm')
                                 ORDER BY   ddt
    END
         , amount
         )  AS amount
  ,   SUM (NVL(d1,0)) OVER ( PARTITION BY  dhcode,to_char(ddt,'yyyymm')
       ,  a_cnt
     ) AS d1
  ,   SUM (NVL(d2,0)) OVER ( PARTITION BY  dhcode,to_char(ddt,'yyyymm')
       ,  a_cnt
     ) AS d2
  ,   SUM (NVL(d3,0)) OVER ( PARTITION BY  dhcode,to_char(ddt,'yyyymm')
       ,  a_cnt
     ) AS d3
  ,   run_tot
  FROM   (
    SELECT d.ddt
    , d.dhsr
    , d.dhcode
    , NVL ( d.damount
                 , h.hamount
             )    AS amount
    , d.d1
    , d.d2
    , d.d3
    , h.hamount - CASE
              WHEN  NVL(d1 + d2 + d3,0) = 0
       THEN  NULL
       ELSE  SUM ( NVL(d.d1
                    + d.d2
            + d.d3,0)
              ) OVER ( PARTITION BY  dhcode,to_char(ddt,'yyyymm')
                        ORDER BY      d.ddt
                 END   AS run_tot
    , COUNT (d1 + d2 + d3) OVER ( PARTITION BY  dhcode,to_char(ddt,'yyyymm')
            ORDER BY      d.ddt  DESC
          ) AS a_cnt
    FROM ddetail     d
    , lheader     h where d.dhcode = h.hcode
           AND d.dhsr  = h.hsr
--WHERE   run_tot IS NOT NULL
WHERE       to_char(ddt,'yyyymm') = '201003'
ORDER BY  ddt
,        dhcode
,   d1 + d2 + d3
i got this output;
DDT              DHSR DHCODE     AMOUNT         D1         D2         D3    RUN_TOT
01/03/2010         12 1392       4489.7          0     16.773     258.22
01/03/2010         12 1392        39573          0     16.773     258.22  48325.336
01/03/2010         14 1526        37745          0      13.21    226.135
01/03/2010         14 1526         5225          0      13.21    226.135
08/03/2010          9 1835    31336.666    131.667     10.968    183.641  31273.724
but the expected result should be like this;
DDT              DHSR DHCODE     AMOUNT         D1         D2         D3    RUN_TOT
01/03/2010         12 1392              39573          0     16.773    258.220  39573.000
01/03/2010         14 1526              37745                13.210    226.135  37745.000
08/03/2010          9 1835          31336.666    131.667     10.968    183.641  31204.999
and when i change the last condition part...to
WHERE   run_tot IS NOT NULL
AND       to_char(ddt,'yyyymm') = '201003'
ORDER BY  ddt
,        dhcode
,   d1 + d2 + d3          ...
DDT              DHSR DHCODE     AMOUNT         D1         D2         D3    RUN_TOT
01/03/2010         12 1392        39573          0     16.773     258.22  48325.336
08/03/2010          9 1835    31336.666    131.667     10.968    183.641  31273.724
   1. The row for dhcode 1526 does not appear and
   2. The runtot for 1835 gets wrongly calculated (it should be 31336.666-131.667=31204.999)Please suggest .
TYVM.

Similar Messages

  • I have Iconia Tab A500, running 3.0, need help updating using microsd card, got Acer update download

    I have Iconia Tab A500 running 3.0, need help updating, I downloaded all updaes list in the acer supprt, all versions, 3.0, 3.1, 3.2, and 4.something, I read on the acer support somewhere I can use a microsd card to update my device, because acer no longer provides automatically, when i try it says "poor network connection, move to anthoer location.", Do I need to update all the listed updates, or can i only update, using the 4. 0? to get the last known update. I also downloaded, "Documents, Apllications, Drivers, Patches, and O.S..... How do i intsall all these updates, I think am running the very lowest version available, Please Help me... Thank you in advance.

    the update listed on the acer website, that mentions the a500 update is 'kernal source code (for Android 4.0 Ice Cream Sandwich) it's 96.7MB's released 2012/05/08' is that the right one i need? There is also a list of 3 O.S updates, released in 2014/09/05, 391.5MB's, 394.3MB's, and 391.5MB's large, what are those updates, I clicked the model and followed the directions that the acer website asks, and i ended with a list of update released in 2014/09/05, and a Document update released in 2014/12/17, 112.7KB's large,  list of updates reased in 2014/.... and in the Android 4.0 culumn, there is an update that says O.S update released in 2014/09/05, 434.2MB's large, and a Patch Update, that was released in 2013/03/21, what are these updates? listedin the aver website... http://www.acer.ca/ac/en/CA/content/drivers 

  • Need modify Running total query

    CREATE TABLE DET
    (DDT DATE,
    DNO NUMBER,
    DCODE VARCHAR2(6),
    DAMOUNT NUMBER,
    DINST NUMBER);
    INSERT INTO DET VALUES (TO_DATE('01012010','DD/MM/YYYY'),7,1946,19674.5,NULL);
    INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),8,1574,4800,NULL);
    INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),8,1574,50000,208.333);
    INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),9,1835,31600,208.333);
    INSERT INTO DET VALUES (TO_DATE('08012010','DD/MM/YYYY'),6,1924,50000,232.558);
    INSERT INTO DET VALUES (TO_DATE('02022010','DD/MM/YYYY'),9,1835,5000,NULL);
    INSERT INTO DET VALUES (TO_DATE('02022010','DD/MM/YYYY'),9,1835,31600,131.667);
    INSERT INTO DET VALUES (TO_DATE('05022010','DD/MM/YYYY'),8,1574,50000,208.333);
    INSERT INTO DET VALUES (TO_DATE('10022010','DD/MM/YYYY'),6,1924,50000,232.558);
    INSERT INTO DET VALUES (TO_DATE('01032010','DD/MM/YYYY'),8,1574,50000,208.333);
    INSERT INTO DET VALUES (TO_DATE('01032010','DD/MM/YYYY'),6,1924,50000,232.558);
    i have this query ;
    SCOTT@orcl>select ddt,
      2  dno,
      3  dcode,
      4  newdamount damount,
      5  dinst,
      6  newdamount-nvl(dinst,0) run_tot
      7  from(
      8  select ddt,
      9  dno,
    10  dcode,
    11  damount,
    12  dinst,
    13  decode(nvl(to_number(to_char(ddt,'MM'))-1,0),0,damount,
    14  damount-nvl(dinst,0)*(to_number(to_char(ddt,'MM'))-1)) newdamount
    15  from det
    16  order by ddt)
    17  where dcode = '1835'
    18  order by ddt,dno,damount,dinst nulls first;
    it returns this result;
    DDT               DNO DCODE     DAMOUNT      DINST    RUN_TOT
    08/01/2010          9 1835        31600    208.333  31391.667
    02/02/2010          9 1835         5000                  5000
    02/02/2010          9 1835    31468.333    131.667  31336.666
    The results last row should appear like this;
    02/02/2010          9 1835    31391.667    131.667  31260 DAMOUNT for the row 02/02/2010 (where DINST > 0 ) should be 31391.667,(closing RUN_TOT of january)
    and NOT 31468.333.
    The above query logic could be enitrely wrong, because the criteria laid assuming that the instalment remains same every month.
    Please someone who is well-verse with Lag or Sum ..Over analytic function, correct my code.
    TY.

    user613563 wrote:
    Your query entirely missed one row with DAMOUNT 5000.
    i expect the result to be;
    DDT               DNO DCODE     DAMOUNT      DINST    RUN_TOT
    08/01/2010          9 1835        31600    208.333  31391.667
    02/02/2010          9 1835         5000                  5000
    02/02/2010          9 1835    31391.667    131.667  31260
    Well, i for one am not following the logic here, but this will give you the results you've posted (why doesn't the row with damount = 5000 factor in to the 'running total' in any way shape or form?)
    select
      ddt, dno, dcode, damount, dinst, resolved
    from
      select
        ddt, dno, dcode, damount, dinst,
        case when lag(trunc(ddt, 'MM')) over (order by ddt asc) != trunc(ddt, 'MM')
        then
          lag(damount-dinst) over (order by ddt asc) - dinst
        else
          damount-dinst
        end as resolved
      from det
      where dcode = '1835'
      and dinst is not null
        union all
      select
        ddt, dno, dcode, damount, dinst,
        damount as resolved
      from det
      where dcode = '1835'
      and dinst is null
      order by ddt asc, dinst nulls first
    )Edited by: Tubby on Jan 11, 2010 2:47 PM
    fixed the not equals sign since the forum eats less than / greater than symbols

  • Rolling totals query ~ please help

    I have been stuck on a query for the last week. It would be amazing if someone could help me with this. nothing I have done has worked so far.  I did post something a few days ago and was helped a bit but it just didnt work out the way I needed. This has been the hardest query I have ever worked on.
    Im using oracle 11g.
    What I am trying to do is get a bunch of running aggregate values based on dates of multiple projects.
    I have did an export of the ddl for the actual table and records, I did not want to just post a sample of the data as it includes many records and I think it might actually be easier to have the full extract.
    here is the link to the file http://santoro.us/pl_insert.sql
    In the table I have IPS (which is a project id), create date, complete date, logged_date, status, due date (these are all the important columns)
    What I am trying to get as an end result is 1 table or 1 view that has all the running totals per month for each project.
    Here are the totals im looking to get
    Open
    Closed
    open late
    closed late
    open on time closed on time
    The thing is I need to start the months per project from the first month the project has a record. So if a projects first record starts on jan 1 2010 thats when the first record with totals should be, 01/2010 , then 02/2010, 03/2010, etc..until the current month. This has to be done per project.
    so for example lets say there are only 2 projects (there are many more).
    IPS 123
    first record starts 01/01/2010
    IPS 456
    first record starts 01/01/2011
    each have records that open and close on different dates in different months. some might be late (complete date > due date),  some closed on time (complete date <= due date).
    end result would be a table that has :
    Date |  IPS | open | closed | open late | closed late | open on time | closed on time |
    01/2010 | 123 | 1 |  0 | etc..
    months would go all the way to current month
    then start proj 2
    01/2011 | 456 | 1 | 0 | etc..
    months would go all the way to current month
    each record would be counted starting the create date of the record. As the records get late or closed (based on due date and complete date) then need to be added/removed from the running totals of the data.
    This all has to be in 1 table or view. I know some people might say this is wrong way to do it but thats how it has to be done for the project im working on. Im generating xml at the end so the developer needs it like this.
    Again thank you for any help and please let me know if you need any other information.
    thank you.

    Frank. No problem. that is great that it doesnt need ad hoc tables and could be done in pure sql. As I said this is the hardest query i have ever worked on. If you could help i would be greatful. I realize this forum is priceless resource and has helped me many times.
    Please let me know if I should post anything else.
    I am having a hard time understanding how I would dispaly each month with the aggregrated rolling totals from start month to current month for each project.
    Im using oracle 11.2.3.3.0
    CREATE TABLE "THERM_PUNCHLIST"
       ( "ENTRY_ID" VARCHAR2(50 BYTE),
      "BATCH_DATE" DATE,
      "IPS" VARCHAR2(50 BYTE),
      "STATUS" VARCHAR2(20 BYTE),
      "DUE_DATE" DATE,
      "UNIT_SERIAL" VARCHAR2(500 BYTE),
      "CREATE_DATE" DATE,
      "COMPLETE_DATE" DATE,
      "DB_LOGGED_DATE" DATE,
      "REPORTED_DATE" DATE
    --im posting more than 20 inserts as i want to be sure to get a few projects. the full ddl is at the link above with all projects and records
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788396',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788387',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788391',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788372',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788375',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788385',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788356',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788360',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('27-MAY-11','DD-MON-RR'),null,to_date('12-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('12-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788338',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('26-JAN-11','DD-MON-RR'),null,to_date('25-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('25-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1788788317',to_date('28-JAN-14','DD-MON-RR'),'102869','Closed',to_date('26-JAN-11','DD-MON-RR'),null,to_date('29-JUN-08','DD-MON-RR'),to_date('28-MAY-09','DD-MON-RR'),to_date('23-AUG-10','DD-MON-RR'),to_date('29-JUN-08','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305623588',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('09-JUN-10','DD-MON-RR'),to_date('08-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('09-JUN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('4073131813',to_date('28-JAN-14','DD-MON-RR'),'504984','Closed',to_date('15-MAY-12','DD-MON-RR'),'E0839',to_date('17-FEB-12','DD-MON-RR'),to_date('31-MAR-12','DD-MON-RR'),to_date('18-APR-12','DD-MON-RR'),to_date('12-DEC-11','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305592103',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('08-JAN-10','DD-MON-RR'),to_date('23-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('08-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305592105',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('08-JAN-10','DD-MON-RR'),to_date('12-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('08-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305592108',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('08-JAN-10','DD-MON-RR'),to_date('12-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('08-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305592101',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('08-JAN-10','DD-MON-RR'),to_date('12-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('08-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305592087',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('08-JAN-10','DD-MON-RR'),to_date('12-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('08-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305592096',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('08-JAN-10','DD-MON-RR'),to_date('12-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('08-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2305592099',to_date('28-JAN-14','DD-MON-RR'),'505587','Closed',to_date('31-JAN-11','DD-MON-RR'),'875032 / 875034',to_date('08-JAN-10','DD-MON-RR'),to_date('12-JUL-10','DD-MON-RR'),to_date('02-MAR-11','DD-MON-RR'),to_date('08-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('3652122705',to_date('28-JAN-14','DD-MON-RR'),'704145','Closed',to_date('01-SEP-10','DD-MON-RR'),null,to_date('13-JUN-10','DD-MON-RR'),to_date('25-APR-11','DD-MON-RR'),to_date('07-FEB-12','DD-MON-RR'),to_date('13-JUN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('3652122696',to_date('28-JAN-14','DD-MON-RR'),'704145','Closed',to_date('01-SEP-10','DD-MON-RR'),null,to_date('13-JUN-10','DD-MON-RR'),to_date('25-APR-11','DD-MON-RR'),to_date('07-FEB-12','DD-MON-RR'),to_date('13-JUN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('3652122693',to_date('28-JAN-14','DD-MON-RR'),'704145','Closed',to_date('01-SEP-10','DD-MON-RR'),null,to_date('13-JUN-10','DD-MON-RR'),to_date('25-APR-11','DD-MON-RR'),to_date('07-FEB-12','DD-MON-RR'),to_date('13-JUN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('4904513300',to_date('28-JAN-14','DD-MON-RR'),'708829','Closed',to_date('04-OCT-12','DD-MON-RR'),'890273',to_date('04-JUL-12','DD-MON-RR'),to_date('09-APR-12','DD-MON-RR'),to_date('05-SEP-12','DD-MON-RR'),to_date('04-JUL-12','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785374403',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('19-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785375257',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('19-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785377988',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843931',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('11-OCT-10','DD-MON-RR'),to_date('02-APR-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('11-OCT-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785384765',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785385084',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785388821',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785388837',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785393519',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-MAR-12','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('28-FEB-12','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785393585',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-MAR-12','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('28-FEB-12','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785375310',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785375318',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785375324',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785378644',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('1785382711',to_date('28-JAN-14','DD-MON-RR'),'504865','Closed',to_date('31-DEC-10','DD-MON-RR'),null,to_date('20-JAN-10','DD-MON-RR'),to_date('07-JUN-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'),to_date('20-JAN-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843992',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('20-AUG-10','DD-MON-RR'),to_date('28-JAN-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843996',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('20-AUG-10','DD-MON-RR'),to_date('23-FEB-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249844002',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('14-MAY-10','DD-MON-RR'),to_date('01-FEB-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('14-MAY-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843984',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('20-AUG-10','DD-MON-RR'),to_date('03-JUN-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843968',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('10-SEP-10','DD-MON-RR'),to_date('14-JAN-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('10-SEP-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843921',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('20-AUG-10','DD-MON-RR'),to_date('28-JAN-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843913',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('20-AUG-10','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'));
    Insert into THERM_PUNCHLIST (ENTRY_ID,BATCH_DATE,IPS,STATUS,DUE_DATE,UNIT_SERIAL,CREATE_DATE,COMPLETE_DATE,DB_LOGGED_DATE,REPORTED_DATE) values ('2249843897',to_date('28-JAN-14','DD-MON-RR'),'701402','Closed',to_date('20-JUN-11','DD-MON-RR'),null,to_date('20-AUG-10','DD-MON-RR'),to_date('03-JUN-11','DD-MON-RR'),to_date('10-FEB-11','DD-MON-RR'),to_date('20-AUG-10','DD-MON-RR'));

  • Trying to form complex query - need help

    I have a fairly complex query that I need to join the results of to show actual and goal by day. The actuals are an aggregation of records that get put in every day, while the targets are a single entry in range format indicating an active range for which the target applies. I'm working on a query that will put things together by month and I'm running into a snag. Can someone please point out where appropriate naming needs to go to get this to come together?
    This one works:
    (select DATE_INDEX, SUM(LDS) as TTLLDS, SUM(TONS) as TTLTONS from
        (select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
           (select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
                 CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
                      ELSE SUM(w.SPOT_WEIGHT)
                  END as WT
              from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
             where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
               and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
               and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
               and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
             group by c.DATE_INDEX, c.VEH_LOC
            union
            select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
                 DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
              from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
             where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
               and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
               and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
             group by c.DATE_INDEX, c.VEH_LOC)
          group by DATE_INDEX, VEH_LOC)
      group by DATE_INDEX)Now I need to add in the following query:
    select (u.MACH_TPH_D+u.MACH_TPH_N)/2 as MTPH_TGT, (u.LABOR_TPH_D+u.LABOR_TPH_N)/2 as LTPH_TGT
         from UTIL_TARGET_LOADERS u
        where u.ORG_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)The join needs to be based on VEH_LOC and DAY in the form:
       ... WHERE u.ORG_ID = x.VEH_LOC
              AND x.DATE_INDEX between u.START_DATE and NVL(u.END_DATE,sysdate)I had one that worked just fine when only one entity was involved; the complication arises in that this is a division-level report so I have to individually resolve the subordinates and their goals before I can aggregate. This is one of two queries I need to tie together using a WITH clause so I can pivot the whole thing and present it in month-by-month fashion. When I try to tie it together like the query below, I get: invalid relational operator.
    select ttls.DATE_INDEX, SUM(ttls.LDS) as TTLLDS, SUM(ttls.TONS) as TTLTONS, u.TARGET_LTPH, u.TARGET_MTPH
      from UTIL_TARGET_LOADERS u,
        (select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
           (select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
                 CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
                      ELSE SUM(w.SPOT_WEIGHT)
                  END as WT
              from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
             where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
               and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
               and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
               and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
             group by c.DATE_INDEX, c.VEH_LOC
            union
            select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
                 DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
              from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
             where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
               and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
               and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
             group by c.DATE_INDEX, c.VEH_LOC)
          group by DATE_INDEX, VEH_LOC) ttls
        where ttls.DATE_INDEX beween u.START_DATE and NVL(u.END_DATE,sysdate)
          and ttls.VEH_LOC = u.ORG_ID
      group by ttls.DATE_INDEXI know this is a nested mess, as it has to grab the production from two tables for a range of VEH_LOC values and sum and aggregate by day and VEH_LOC, then I have to try and match that to the targets based on VEH_LOC and day. My final query is to aggregate the whole mess of sums and averages by month.
    I'd appreciate it if someone can point me in the right direction.

    Figured it out.
    select ttl.DATE_INDEX, SUM(ttl.LDS) as TTLLDS, SUM(ttl.TONS) as TTLTONS,
         AVG((u.MACH_TPH_D+u.MACH_TPH_N)/2) as MTPH_TGT,
         AVG((u.LABOR_TPH_D+u.LABOR_TPH_N)/2) as LTPH_TGT
      from
        (select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
           (select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
                 CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
                      ELSE SUM(w.SPOT_WEIGHT)
                  END as WT
              from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
             where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
               and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
               and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
               and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
             group by c.DATE_INDEX, c.VEH_LOC
            union
            select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
                 DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
              from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
             where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
               and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
               and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
             group by c.DATE_INDEX, c.VEH_LOC)
          group by DATE_INDEX, VEH_LOC) ttl, UTIL_TARGET_LOADERS u
      where u.ORG_ID = ttl.VEH_LOC
        and ttl.DATE_INDEX between u.START_DATE and NVL(U.END_DATE,sysdate)
      group by ttl.DATE_INDEX, (u.LABOR_TPH_D+u.LABOR_TPH_N)/2

  • Running long time- need help

    Following Query running more than 4 hrs. could somone please suggest me to tune this query.
    SELECT fi_contract_id, a.cust_id, a.product_id, a.currency_cd,
    ROUND (DECODE (SUBSTR (a.ACCOUNT, 1, 4), '4992', posted_tran_amt, 0),
    2
    ) ftp_amt,
    ROUND (DECODE (SUBSTR (a.ACCOUNT, 1, 4), '4992', posted_base_amt, 0),
    2
    ) ftp_base_amt,
    ROUND (DECODE (SUBSTR (a.ACCOUNT, 1, 4),
    '4994', posted_tran_amt,
    '4995', posted_tran_amt,
    0
    2
    ) col_amt,
    ROUND (DECODE (SUBSTR (a.ACCOUNT, 1, 4),
    '4994', posted_base_amt,
    '4995', posted_base_amt,
    0
    2
    ) col_base_amt,
    ROUND (DECODE (SUBSTR (a.ACCOUNT, 1, 3), '499', 0, posted_tran_amt),
    2
    ) closing_bal,
    a.ACCOUNT, a.deptid, a.business_unit,
    CASE
    WHEN a.ACCOUNT LIKE '499%'
    THEN '990'
    ELSE a.operating_unit
    END operating_unit,
    a.base_currency, NVL (TRIM (pf_system_code), a.SOURCE) pf_system_code,
    b.setid, a.channel_id, scb_arm_code, scb_tp_product, scb_tranche_id,
    CASE
    WHEN pf_system_code = 'CLS'
    THEN scb_bncpr_flg
    ELSE NULL
    END tranche_purpose,
    CASE
    WHEN pf_system_code = 'IMX'
    AND SUBSTR (scb_bncpr_flg, 1, 1) IN ('Y', 'N')
    THEN SUBSTR (scb_bncpr_flg, 1, 1)
    ELSE NULL
    END lc_ind,
    CASE
    WHEN pf_system_code = 'IMX'
    AND SUBSTR (scb_bncpr_flg, 1, 1) IN ('Y', 'N')
    THEN SUBSTR (scb_bncpr_flg, 2, 3)
    WHEN pf_system_code = 'IMX'
    AND SUBSTR (scb_bncpr_flg, 1, 1) NOT IN ('Y', 'N')
    THEN SUBSTR (scb_bncpr_flg, 1, 3)
    ELSE NULL
    END bill_branch_id,
    CASE
    WHEN pf_system_code = 'IMX'
    AND SUBSTR (scb_bncpr_flg, 1, 1) IN ('Y', 'N')
    THEN SUBSTR (scb_bncpr_flg, 5, 1)
    WHEN pf_system_code = 'IMX'
    AND SUBSTR (scb_bncpr_flg, 1, 1) NOT IN ('Y', 'N')
    THEN SUBSTR (scb_bncpr_flg, 4, 1)
    ELSE NULL
    END section_id,
    CASE
    WHEN pf_system_code = 'IFS'
    THEN SUBSTR (scb_bncpr_flg, 1, 1)
    ELSE NULL
    END recourse_ind,
    CASE
    WHEN pf_system_code = 'IFS'
    THEN SUBSTR (scb_bncpr_flg, 2, 1)
    ELSE NULL
    END disclosure_ind,
    TO_CHAR (LAST_DAY (upload_date), 'DDMMYYYY')
    FROM ps_fi_ildgr_f00 a,
    (SELECT c.business_unit, c.fi_instrument_id, c.scb_arm_code,
    c.scb_tp_product, c.scb_tranche_id, c.scb_bncpr_flg
    FROM ps_fi_iother_r00 c, ps_scb_bus_unit b1
    WHERE c.business_unit = b1.business_unit
    AND b1.setid = 'PKSTN'
    AND c.asof_dt =
    (SELECT MAX (c1.asof_dt)
    FROM ps_fi_iother_r00 c1
    WHERE c.business_unit = c1.business_unit
    AND c1.fi_instrument_id = c.fi_instrument_id)) c,
    ps_scb_bus_unit b,
    (SELECT upload_date - 15 upload_date
    FROM stg_ftp_trans_bal_tb
    WHERE setid = 'PKSTN' AND ROWNUM < 2),
    (SELECT i.business_unit, i.fi_instrument_id, i.pf_system_code,
    i.fi_contract_id
    FROM ps_fi_instr_f00 i, ps_scb_bus_unit b1
    WHERE i.business_unit = b1.business_unit
    AND b1.setid = 'PKSTN'
    AND (i.asof_dt) =
    (SELECT MAX (i1.asof_dt)
    FROM ps_fi_instr_f00 i1
    WHERE i.business_unit = i1.business_unit
    AND i1.fi_instrument_id = i.fi_instrument_id)) d
    WHERE a.business_unit = b.business_unit
    AND a.business_unit = c.business_unit
    AND a.business_unit = d.business_unit
    AND a.fi_instrument_id = c.fi_instrument_id(+)
    AND a.fi_instrument_id = d.fi_instrument_id(+)
    AND fiscal_year = TO_CHAR (upload_date, 'YYYY')
    AND a.ACCOUNT != '191801'
    AND a.pf_scenario_id LIKE '%M_'
    AND accounting_period = TO_CHAR (upload_date, 'MM')
    AND b.setid = 'PKSTN'
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
    | 0 | SELECT STATEMENT | | 1 | 225 | | 14059 (2)| | | | | |
    |* 1 | FILTER | | | | | | | | | | |
    | 2 | PX COORDINATOR | | | | | | | | | | |
    | 3 | PX SEND QC (RANDOM) | :TQ10006 | 962 | 211K| | 13578 (2)| | | Q1,06 | P->S | QC (RAND) |
    |* 4 | HASH JOIN | | 962 | 211K| | 13578 (2)| | | Q1,06 | PCWP | |
    | 5 | PX RECEIVE | | 977 | 190K| | 4273 (2)| | | Q1,06 | PCWP | |
    | 6 | PX SEND BROADCAST | :TQ10004 | 977 | 190K| | 4273 (2)| | | Q1,04 | P->P | BROADCAST |
    PLAN_TABLE_OUTPUT
    |* 7 | HASH JOIN | | 977 | 190K| | 4273 (2)| | | Q1,04 | PCWP | |
    | 8 | BUFFER SORT | | | | | | | | Q1,04 | PCWC | |
    | 9 | PX RECEIVE | | 1 | 10 | | 2 (0)| | | Q1,04 | PCWP | |
    | 10 | PX SEND BROADCAST | :TQ10000 | 1 | 10 | | 2 (0)| | | | S->P | BROADCAST |
    |* 11 | TABLE ACCESS FULL | PS_SCB_BUS_UNIT | 1 | 10 | | 2 (0)| | | | | |
    | 12 | TABLE ACCESS BY LOCAL INDEX ROWID| PS_FI_INSTR_F00 | 1 | 42 | | 1 (0)| | | Q1,04 | PCWC | |
    | 13 | NESTED LOOPS | | 1954 | 362K| | 4271 (2)| | | Q1,04 | PCWP | |
    |* 14 | HASH JOIN | | 1954 | 282K| | 3999 (2)| | | Q1,04 | PCWP | |
    | 15 | BUFFER SORT | | | | | | | | Q1,04 | PCWC | |
    | 16 | PX RECEIVE | | 1 | 10 | | 2 (0)| | | Q1,04 | PCWP | |
    | 17 | PX SEND BROADCAST | :TQ10001 | 1 | 10 | | 2 (0)| | | | S->P | BROADCAST |
    PLAN_TABLE_OUTPUT
    |* 18 | TABLE ACCESS FULL | PS_SCB_BUS_UNIT | 1 | 10 | | 2 (0)| | | | | |
    |* 19 | HASH JOIN | | 3907 | 526K| | 3997 (2)| | | Q1,04 | PCWP | |
    | 20 | PX RECEIVE | | 54702 | 4700K| | 616 (1)| | | Q1,04 | PCWP | |
    | 21 | PX SEND HASH | :TQ10003 | 54702 | 4700K| | 616 (1)| | | Q1,03 | P->P | HASH |
    | 22 | PX BLOCK ITERATOR | | 54702 | 4700K| | 616 (1)| 1 | 6119 | Q1,03 | PCWC | |
    |* 23 | TABLE ACCESS FULL | PS_FI_ILDGR_F00 | 54702 | 4700K| | 616 (1)| 1 | 6119 | Q1,03 | PCWP | |
    | 24 | BUFFER SORT | | | | | | | | Q1,04 | PCWC | |
    | 25 | PX RECEIVE | | 221K| 10M| | 3380 (3)| | | Q1,04 | PCWP | |
    | 26 | PX SEND HASH | :TQ10002 | 221K| 10M| | 3380 (3)| | | | S->P | HASH |
    | 27 | NESTED LOOPS | | 221K| 10M| | 3380 (3)| | | | | |
    | 28 | NESTED LOOPS | | 1 | 16 | | 2351 (2)| | | | | |
    PLAN_TABLE_OUTPUT
    | 29 | VIEW | | 1 | 6 | | 2349 (2)| | | | | |
    |* 30 | COUNT STOPKEY | | | | | | | | | | |
    | 31 | PARTITION LIST SINGLE | | 661K| 7755K| | 2349 (2)| KEY | KEY | | | |
    | 32 | TABLE ACCESS FULL | STG_FTP_TRANS_BAL_TB | 661K| 7755K| | 2349 (2)| 2 | 2 | | | |
    |* 33 | TABLE ACCESS FULL | PS_SCB_BUS_UNIT | 1 | 10 | | 2 (0)| | | | | |
    | 34 | PARTITION LIST ITERATOR | | 442K| 14M| | 1029 (3)| KEY | KEY | | | |
    |* 35 | TABLE ACCESS FULL | PS_FI_IOTHER_R00 | 442K| 14M| | 1029 (3)| KEY | KEY | | | |
    | 36 | PARTITION LIST ITERATOR | | 1 | | | 1 (0)| KEY | KEY | Q1,04 | PCWP | |
    |* 37 | INDEX RANGE SCAN | PS_FI_INSTR_F00 | 1 | | | 1 (0)| KEY | KEY | Q1,04 | PCWP | |
    | 38 | VIEW | VW_SQ_1 | 5220K| 124M| | 9296 (1)| | | Q1,06 | PCWP | |
    | 39 | SORT GROUP BY | | 5220K| 169M| 479M| 9296 (1)| | | Q1,06 | PCWP | |
    PLAN_TABLE_OUTPUT
    | 40 | PX RECEIVE | | 5220K| 169M| | 9220 (1)| | | Q1,06 | PCWP | |
    | 41 | PX SEND HASH | :TQ10005 | 5220K| 169M| | 9220 (1)| | | Q1,05 | P->P | HASH |
    | 42 | PX BLOCK ITERATOR | | 5220K| 169M| | 9220 (1)| 1 | 7 | Q1,05 | PCWC | |
    | 43 | TABLE ACCESS FULL | PS_FI_INSTR_F00 | 5220K| 169M| | 9220 (1)| 1 | 7 | Q1,05 | PCWP | |
    | 44 | SORT AGGREGATE | | 1 | 20 | | | | | | | |
    | 45 | PARTITION LIST SINGLE | | 1 | 20 | | 1 (0)| KEY | KEY | | | |
    |* 46 | INDEX RANGE SCAN | PS_FI_IOTHER_R00 | 1 | 20 | | 1 (0)| KEY | KEY | | | |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    1 - filter("C"."ASOF_DT"= (SELECT /*+ */ MAX("C1"."ASOF_DT") FROM "PS_FI_IOTHER_R00" "C1" WHERE "C1"."FI_INSTRUMENT_ID"=:B1 AND
    "C1"."BUSINESS_UNIT"=:B2))
    4 - access("I"."ASOF_DT"="VW_COL_1" AND "I"."BUSINESS_UNIT"="BUSINESS_UNIT" AND "FI_INSTRUMENT_ID"="I"."FI_INSTRUMENT_ID")
    7 - access("I"."BUSINESS_UNIT"="B1"."BUSINESS_UNIT")
    11 - filter("B1"."SETID"='PKSTN')
    14 - access("A"."BUSINESS_UNIT"="B"."BUSINESS_UNIT")
    18 - filter("B"."SETID"='PKSTN')
    19 - access("A"."BUSINESS_UNIT"="C"."BUSINESS_UNIT" AND "A"."FI_INSTRUMENT_ID"="C"."FI_INSTRUMENT_ID" AND
    "FISCAL_YEAR"=TO_NUMBER(TO_CHAR("UPLOAD_DATE",'YYYY')) AND "ACCOUNTING_PERIOD"=TO_NUMBER(TO_CHAR("UPLOAD_DATE",'MM')))
    23 - filter("A"."PF_SCENARIO_ID" LIKE '%M_' AND "A"."ACCOUNT"<>'191801')
    PLAN_TABLE_OUTPUT
    30 - filter(ROWNUM<2)
    33 - filter("B1"."SETID"='PKSTN')
    35 - filter("C"."BUSINESS_UNIT"="B1"."BUSINESS_UNIT")
    37 - access("A"."BUSINESS_UNIT"="I"."BUSINESS_UNIT" AND "A"."FI_INSTRUMENT_ID"="I"."FI_INSTRUMENT_ID")
    46 - access("C1"."BUSINESS_UNIT"=:B1 AND "C1"."FI_INSTRUMENT_ID"=:B2)
    Note
    - 'PLAN_TABLE' is old version
    75 rows selected.

    [email protected] wrote:
    Following Query running more than 4 hrs. could somone please suggest me to tune this query.1. You can try to avoid self-joins or FILTER operations in the C and D inline views if you change below queries to use analytic functions instead:
    (SELECT c.business_unit, c.fi_instrument_id, c.scb_arm_code,
    c.scb_tp_product, c.scb_tranche_id, c.scb_bncpr_flg
    FROM ps_fi_iother_r00 c, ps_scb_bus_unit b1
    WHERE c.business_unit = b1.business_unit
    AND b1.setid = 'PKSTN'
    AND c.asof_dt =
    (SELECT MAX (c1.asof_dt)
    FROM ps_fi_iother_r00 c1
    WHERE c.business_unit = c1.business_unit
    AND c1.fi_instrument_id = c.fi_instrument_id)) c,
    (SELECT upload_date - 15 upload_date
    FROM stg_ftp_trans_bal_tb
    WHERE setid = 'PKSTN' AND ROWNUM < 2),
    (SELECT i.business_unit, i.fi_instrument_id, i.pf_system_code,
    i.fi_contract_id
    FROM ps_fi_instr_f00 i, ps_scb_bus_unit b1
    WHERE i.business_unit = b1.business_unit
    AND b1.setid = 'PKSTN'
    AND (i.asof_dt) =
    (SELECT MAX (i1.asof_dt)
    FROM ps_fi_instr_f00 i1
    WHERE i.business_unit = i1.business_unit
    AND i1.fi_instrument_id = i.fi_instrument_id)) d
    ...Try to use something like this instead:
    (select * from
    (SELECT c.business_unit, c.fi_instrument_id, c.scb_arm_code,
            c.scb_tp_product, c.scb_tranche_id, c.scb_bncpr_flg,
            rank() over (order by c.asof_dt desc partition by c.business_unit, c.fi_instrument_id) rnk
       FROM ps_fi_iother_r00 c, ps_scb_bus_unit b1
      WHERE c.business_unit = b1.business_unit
        AND b1.setid = 'PKSTN')
    where rnk = 1) c,
    ...2. This piece seems to be questionable since it seems to pick the "UPLOAD_DATE" from an arbitrary row where SETID = 'PKSTN'. I assume that the UPLOAD_DATE is then the same for all these rows, otherwise this would potentially return a different UPLOAD_DATE for each execution of the query. Still it's a questionable approach and seems to be de-normalized data.
    (SELECT upload_date - 15 upload_date
    FROM stg_ftp_trans_bal_tb
    WHERE setid = 'PKSTN' AND ROWNUM < 2),3. Your execution plan contains some parts that are questionable and might lead to inappropriate work performed by the database if the estimates of optimizer are wrong:
    a. Are you sure that the filter predicate "SETID"='PKSTN' on PS_SCB_BUS_UNIT returns only a single row? If not, below NESTED LOOP operation could scan the PS_FI_IOTHER_R00 table more than once making this rather inefficient
    |  27 |                NESTED LOOPS              |                      |   221K|    10M|       |  3380   (3)|       |       |        |      |            |
    |  28 |                 NESTED LOOPS             |                      |     1 |    16 |       |  2351   (2)|       |       |        |      |            |
    |  29 |                  VIEW                    |                      |     1 |     6 |       |  2349   (2)|       |       |        |      |            |
    |* 30 |                   COUNT STOPKEY          |                      |       |       |       |            |       |       |        |      |            |
    |  31 |                    PARTITION LIST SINGLE |                      |   661K|  7755K|       |  2349   (2)|   KEY |   KEY |        |      |            |
    |  32 |                     TABLE ACCESS FULL    | STG_FTP_TRANS_BAL_TB |   661K|  7755K|       |  2349   (2)|     2 |     2 |        |      |            |
    |* 33 |                  TABLE ACCESS FULL       | PS_SCB_BUS_UNIT      |     1 |    10 |       |     2   (0)|       |       |        |      |            |
    |  34 |                 PARTITION LIST ITERATOR  |                      |   442K|    14M|       |  1029   (3)|   KEY |   KEY |        |      |            |
    |* 35 |                  TABLE ACCESS FULL       | PS_FI_IOTHER_R00     |   442K|    14M|       |  1029   (3)|   KEY |   KEY |        |      |            |b. The optimizer assumes that below join returns only 3907 rows out of the 54k and 221k source sets. This could be wrong, because the join expression contains multiple function calls and an implicit TO_NUMBER conversion you haven't mentioned in your SQL which is bad practice in general:
    19 - access("A"."BUSINESS_UNIT"="C"."BUSINESS_UNIT" AND "A"."FI_INSTRUMENT_ID"="C"."FI_INSTRUMENT_ID" AND
    "FISCAL_YEAR"=TO_NUMBER(TO_CHAR("UPLOAD_DATE",'YYYY')) AND "ACCOUNTING_PERIOD"=TO_NUMBER(TO_CHAR("UPLOAD_DATE",'MM')))The conversion functions might hide from the optimizer that the join returns many more rows than estimated, because the optimizer uses default selectivities or guesses for function expressions. If you can't fix the data model to use appropriate join expressions you could try to create function based indexes on the expressions TO_NUMBER(TO_CHAR("UPLOAD_DATE",'YYYY')) and TO_NUMBER(TO_CHAR("UPLOAD_DATE",'MM')) and gather statistics on the corresponding hidden columns (method_opt parameter of DBMS_STATS.GATHER_TABLE_STATS call set to "FOR ALL HIDDEN COLUMNS"). If you're already on 11g you can achieve the same by using virtual columns.
    |* 19 |            HASH JOIN                     |                      |  3907 |   526K|       |  3997   (2)|       |       |  Q1,04 | PCWP |            |
    |  20 |             PX RECEIVE                   |                      | 54702 |  4700K|       |   616   (1)|       |       |  Q1,04 | PCWP |            |
    |  21 |              PX SEND HASH                | :TQ10003             | 54702 |  4700K|       |   616   (1)|       |       |  Q1,03 | P->P | HASH       |
    |  22 |               PX BLOCK ITERATOR          |                      | 54702 |  4700K|       |   616   (1)|     1 |  6119 |  Q1,03 | PCWC |            |
    |* 23 |                TABLE ACCESS FULL         | PS_FI_ILDGR_F00      | 54702 |  4700K|       |   616   (1)|     1 |  6119 |  Q1,03 | PCWP |            |
    |  24 |             BUFFER SORT                  |                      |       |       |       |            |       |       |  Q1,04 | PCWC |            |
    |  25 |              PX RECEIVE                  |                      |   221K|    10M|       |  3380   (3)|       |       |  Q1,04 | PCWP |            |
    |  26 |               PX SEND HASH               | :TQ10002             |   221K|    10M|       |  3380   (3)|       |       |        | S->P | HASH       |
    |  27 |                NESTED LOOPS              |                      |   221K|    10M|       |  3380   (3)|       |       |        |      |            |
    |  28 |                 NESTED LOOPS             |                      |     1 |    16 |       |  2351   (2)|       |       |        |      |            |
    |  29 |                  VIEW                    |                      |     1 |     6 |       |  2349   (2)|       |       |        |      |            |
    |* 30 |                   COUNT STOPKEY          |                      |       |       |       |            |       |       |        |      |            |
    |  31 |                    PARTITION LIST SINGLE |                      |   661K|  7755K|       |  2349   (2)|   KEY |   KEY |        |      |            |
    |  32 |                     TABLE ACCESS FULL    | STG_FTP_TRANS_BAL_TB |   661K|  7755K|       |  2349   (2)|     2 |     2 |        |      |            |
    |* 33 |                  TABLE ACCESS FULL       | PS_SCB_BUS_UNIT      |     1 |    10 |       |     2   (0)|       |       |        |      |            |
    |  34 |                 PARTITION LIST ITERATOR  |                      |   442K|    14M|       |  1029   (3)|   KEY |   KEY |        |      |            |
    |* 35 |                  TABLE ACCESS FULL       | PS_FI_IOTHER_R00     |   442K|    14M|       |  1029   (3)|   KEY |   KEY |        |      |            |c. Due to the small number of rows estimated, mainly caused by b. above, the result of the joins is broadcasted to all parallel slaves when performing the final join. This might be quite inefficient if the result is much larger than expected.
    |   6 |       PX SEND BROADCAST                  | :TQ10004             |   977 |   190K|       |  4273   (2)|       |       |  Q1,04 | P->P | BROADCAST  |Note that this join is not necessary any longer / obsolete if you introduce above analytic functions as suggested.
    4. Your PLAN_TABLE does not match your Oracle version. If you're already on 10g or later, simply drop all PLAN_TABLEs in non-SYS schemas since there is already one provided as part of the data dictionary. Otherwise re-create them using $ORACLE_HOME/rdbms/admin/utlxplan.sql
    Note
    - 'PLAN_TABLE' is old versionIf you want to understand where the majority of the time is spent you need to trace the execution. Note that your statement introduces an increased complexity because it uses parallel execution, therefore you'll end up with multiple trace files per parallel slave and query coordinator process, which makes the analysis not that straightforward.
    Please read this HOW TO: Post a SQL statement tuning request - template posting that explains how you can enable the statement trace and what you should provide if you have SQL statement tuning question and how to format it here so that the posted information is readable by others.
    This accompanying blog post shows step-by-step instructions how to obtain that information.
    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/

  • What's wrong with this query--need help

    Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
    select ename
    from emp
    where to_char(hiredate,'day')='tuesday';
    when i execute the query
    o/p is no rows selected
    please help.
    thanks in advance.

    Hi,
    861173 wrote:
    Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
    select ename
    from emp
    where to_char(hiredate,'day')='tuesday';
    when i execute the query
    o/p is no rows selected Try:
    WHERE   TO_CHAR (hiredate, 'fmday')  = 'tuesday'Without 'FM" in the 2nd argument, TO_CHAR pads the results to make it a consistent length. If your NLS_DATE_LANGUAGE=ENGLISH, that means it will always return a 9-character string, since the longest name in English ('Wednesday') has 9 letters. 'FM' (case-insernsitive) tells TO_CHAR not to add that kind of padding.

  • Leopard Suddenly Running Slowly and Need Help

    Hi there. I have been a Mac user (and Mac support person at work) for many years. I've recently run into a problem that I'd like some help with.
    I have an iMac that I bought 4 months ago, and I upgraded to Leopard and then put 10.5.1 update onto it.
    Nothing of any note has occurred with my computer in the last 2 days, however, 2 days ago, every application started running very slowly. I click on the HD icon, and the spinning color cursor spins for 30-40 seconds before the HD opens. I click in the bottom tray to open Safari, and it takes 40-50 seconds for it to open (as the color cursor spins away). I reboot, and the iMac comes up with the front white/gray screen and holds with the spinning circle for anywhere from 20 to 45 MINUTES before going to the desktop. I have reinstalled Leopard (telling it to Archive and Install). Same problems abound. I ran Tech Tool, and it says everything is fine. I started up from the Leopard install DVD and ran Disk Utility. Checking the progress log, it tells me that the HD cannot be unmounted (meantime, I've booted from the DVD and nothing else is attached or running). When I select "Repair Disk" in Disk Utility, I get an immediate message that the HD cannot be unmounted.
    What does this sound like? A hard drive failure? Will completely erasing my HD and installing Leopard from scratch (as opposed to installing Tiger and upgrading to Leopard) help? Or am I merely band-aiding the problem and need to take it in for qualified Apple Tech support?
    I'd appreciate any help.
    Thanks.

    Hi and welcome to the Apple forums.
    I would run DU and check the disk and the permissions.
    If necessary use DiskWarrior
    You might also zap the PRAM and NV-RAM.
    Check the console log, other logs and of course the activity monitor.
    If it is noticeably slower, what is causing it should be rather obvious.
    It could be a failing drive that is being re-read multiple times to extract data from a bad block/sector.
    Be sure you have everything backed up. !!!
    Message was edited by: nerowolfe

  • Native SQL query - Need help

    Hi All,
    We have a native SQL query accessing Oracle database(given below).
    Can anyone please let me know what this query is about and how can we fine tune the query?
    SELECT O.OBJECT_NAME ,
                   H.SID,
                   HS.MACHINE,
                   HS.PROCESS,
                   W.SID,
                   WS.MACHINE,
                   WS.PROCESS,
                   H.CTIME,
                   W.CTIME,
                   WS.ROW_WAIT_OBJ#,
                   WS.ROW_WAIT_FILE#,
                   WS.ROW_WAIT_BLOCK#,
                   WS.ROW_WAIT_ROW#,
                   HP.SPID,
                   WP.SPID
            FROM V$LOCK H, V$LOCK W, V$LOCK I, V$LOCK I2, ALL_OBJECTS O,
                 V$SESSION HS, V$SESSION WS, V$PROCESS HP, V$PROCESS WP
            WHERE   H.ID1 = W.ID1
            AND     H.SID <> W.SID
            AND     H.TYPE IN ('TX','DL')
            AND     H.REQUEST = 0
            AND     H.SID = I.SID
            AND     I.TYPE = 'TM'
            AND     I.ID1 = O.OBJECT_ID
            AND     I.ID1 = I2.ID1
            AND     W.SID = I2.SID
            AND     I2.TYPE = 'TM'
            AND     H.SID = HS.SID
            AND     W.SID = WS.SID
            AND     HS.PADDR = HP.ADDR
            AND     WS.PADDR = WP.ADDR
            INTO :EXCL_LOCK_WAITERS-OBJ_NAME   ,
                 :EXCL_LOCK_WAITERS-HOLDER_SID ,
                 :EXCL_LOCK_WAITERS-H_HOSTNAME ,
                :EXCL_LOCK_WAITERS-HOLDER_PID ,
                 :HOLDER_PID ,
                 :EXCL_LOCK_WAITERS-WAITER_SID ,
                 :EXCL_LOCK_WAITERS-W_HOSTNAME ,
                :EXCL_LOCK_WAITERS-WAITER_PID ,
                 :WAITER_PID ,
                 :EXCL_LOCK_WAITERS-HELD_SINCE ,
                 :EXCL_LOCK_WAITERS-WAITSSINCE,
                 :ROW_WAIT_OBJ,
                 :ROW_WAIT_FILE,
                 :ROW_WAIT_BLOCK,
                 :ROW_WAIT_ROW,
                 :H_PROCESS,
                 :W_PROCESS
          ENDEXEC
    Thanks in advance.
    Neethu Mohan

    Hi Neethu,
    It gives you an overwiew of blocking Oracle sessions.
    1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX)  to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX')  => holders
    It joins these with the sessions that are waiting of releasing the lock by the holders  => waiters.
    2. it retrieves the detail information wich  Oracle process , the object (table) , it's row , block  and file
    are affected by the locks.
    3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.
    4. Tuning
    V$tables are expensive to query: Why?
    v$ tables are generally Oracle memory structures.
    v$ tables are not read consistent.
    v$ tables require latches to access -- cannot modify and read memory at the same
    time.
    heavy access to v$ tables like this may cause some serious heavy duty contention.
    Especially if you self join V$lock several times.
    So the best would be to save the contents of V$LOCK in some table:
    Create table mylocks as select * from v$lock;
    Use that table for self-joining and joins to the other tables.
    You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving
    v$ directly.
    You can empty or drop the created tables any time for new data.
    Because you want to investigate only lock hold for a longert time  to copy the v$ memory structures into
    physical tables is not a disadvantage. You certainly will wait longer on finishing your query
    instead of copy them into the tables.
    Hope this helped
    yk

  • Row_number query - need help ASAP

    Hi ,
    Need some help bout query
    I need a query for display output like below
    DATE          CODE     MAC_NO BATCH_NO
    01-OCT-07     1119     02     1
    20-OCT-07     1210     01     2
    01-NOV-07     1209     01     3
    01-NOV-07     1510     01     4
    01-NOV-07     4025     01     5
    01-NOV-07     4025     01     5
    01-NOV-07     4051     03     6
    02-NOV-07     1209     01     7
    i hv no idea how to do it. My query doesn't work for tat requirement.Tis is my query
    SELECT date
    ,code
    ,mac_no
    ,ROW_NUMBER()
    OVER (PARTITION by date,code,mac_no
    ORDER by date,code,mac_no)
    as batch_no
    FROM PAYMENT
    WHERE npcs_cycle_num = 27
    AND txn_insert_seq_num > 0;
    The output juz like below.I need everybody help ASAP.
    DATE          CODE     MAC_NO BATCH_NO
    01-OCT-07     1119     02     1
    20-OCT-07     1210     01     1
    01-NOV-07     1209     01     1
    01-NOV-07     1510     01     1
    01-NOV-07     4025     01     1
    01-NOV-07     4025     01     2
    01-NOV-07     4051     03     1
    02-NOV-07     1209     01     1
    Thanks
    CT

    I'm sorry..Maybe my words it not that clear enough. You were right about how ROW_NUMBER works (it
    assigns a numeric value and resets based on the grouping you specify in the PARTITION clause).
    What I want actually is the row number increment based on the txn_date,poc_code and machine_no.
    I'm not sure whether using the row_number() can solve my solutions. I really hope that you could help me.
    I thought of using row_number() may help. Do you have any other solution?
    Here is my table description.
    DESC PAYMENT;
    Name Null? Type
    TXN_ID_NUM NOT NULL NUMBER(12)
    ACCT_NO NOT NULL VARCHAR2(14)
    CANCEL_CODE VARCHAR2(5)
    ADJ_TYPE_NO VARCHAR2(2)
    REASON_CODE VARCHAR2(5)
    CASHIER_ID_NO VARCHAR2(10)
    SUPERVISOR_ID_NO VARCHAR2(10)
    REV_CODE VARCHAR2(5)
    TXN_DATE DATE
    PAY_ADJ_DATE DATE
    POC_CODE VARCHAR2(10)
    MACHINE_NO VARCHAR2(3)
    PAY_MODE_CODE VARCHAR2(5)
    ORIG_ACCT_NO VARCHAR2(14)
    PAY_AMT NUMBER(12,2)
    INVOICE_NO VARCHAR2(20)
    PAY_RECEIPT_NO VARCHAR2(24)
    PAY_BATCH_NO VARCHAR2(20)
    NPCS_CYCLE_NUM NUMBER(4)
    TXN_INSERT_SEQ_NUM NOT NULL NUMBER(12)
    2) Below is the query before assigning the row number:
    SQL> SELECT TXN_DATE,POC_CODE,MACHINE_NO,PAY_BATCH_NO,PAY_AMT,REV_CODE,ADJ_TYPE_NO,PAY_MODE_CODE
    2 FROM PAYMENT
    3 WHERE NPCS_CYCLE_NUM=27
    4 AND REV_CODE IN (SELECT rev_code
    5 FROM OUTBND_REV_CODE
    6 WHERE outbnd_agen_file_code = 'TMB'
    7 AND sys_appl_id ='CCC')
    8 ORDER BY TXN_DATE,POC_CODE,MACHINE_NO;
    TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M
    01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1
    20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5
    01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1
    01-NOV-07 1510 01 20071101402501100000 493 014 00 1
    01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3     
    01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1
    01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3
    02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1
    3)This is my query and the result:
    SQL> SELECT /* SQL_ID 2703 */
    2 txn_date
    3 ,poc_code
    4 ,machine_no
    5 ,pay_batch_no
    6 ,pay_amt
    7 ,rev_code
    8 ,adj_type_no
    9 ,pay_mode_code
    10 ,ROW_NUMBER()
    11 OVER (PARTITION by txn_date,poc_code,machine_no
    12 ORDER by txn_date,poc_code,machine_no)
    13 as row_number
    14 FROM PAYMENT
    15 WHERE npcs_cycle_num = 27
    16 AND txn_insert_seq_num > 0
    17 AND rev_code IN (SELECT rev_code
    18 FROM OUTBND_REV_CODE
    19 WHERE outbnd_agen_file_code = 'TMB'
    20 AND sys_appl_id ='CCC');
    TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M ROW_NUMBER
    01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1 1 (1)
    20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5 1 (2)
    01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1 1 (3)
    01-NOV-07 1510 01 20071101402501100000 493 014 00 1 1 (4)
    01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3 1 (5)
    01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1 2 (5)
    01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3 1 (6)
    02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1 1 (7)
    8 rows selected.
    What I want actually as in the bracket (group by three fields which are txn_date,poc_code and machine_no)
    .I hope this is clearer.

  • Heterogeneous Query, need help ASAP!

    Post Author: zen69
    CA Forum: Data Connectivity and SQL
    Hi all! I'm trying to make a report that uses a view with linked table (tables from a linked server).I tested my view in  SQL Server and it's working but when I try to use it in my report I get these two error messages:Error #1:     Failed to retrieve data from the databaseError #2:   
    Failed to retrieve data from the database.    Details:
    42000:&#91;Microsoft&#93;&#91;ODBC SQL Server Driver&#93;&#91;SQL Server&#93;Heterogeneous queries
    require the ANSI_NULLS and ANSI_WARNINGS options to be set for the
    connection. This ensures cosistent query semantics. Enable these options and
    then reissue your query. &#91;Database Vendor Code: 7405 &#93;I'm using
    Crystal Reports CR Professional; Product Type: FullVersion : 11.0.0.895. Please help me ASAP, I really need it to be done! Thanks,J.B.

    Post Author: zen69
    CA Forum: Data Connectivity and SQL
    I forgot to say that I'm using MS SQL Server 2005...

  • Run-time errors--need help

    Hi everyone,
    I'd greatly appreciate some help with this java program...here's the problem:
    Create a class Person that does the following:
    1. Set the Last Name only
    2. Set the First Name only
    3. Set the Middle Name only
    4. Gets the First Name
    5. Gets the Middle Name
    6. Gets the Last Name
    7. Check whether a given last name is the same as the last name of this person.
    8. Check whether a given last name is the same as the first name of this person.
    9. Check whether a given first name is the same as the middle name of this person.
    10. A method called equals that returns true if two objects contains the same first, middle, and last name
    11. A method called makeCopy that copies the instance variables of a Person object into another Person object.
    12. A method called getCopy that creates and returns the address of the object, which is a copy of another person object.
    13. A method for a copy constructor.
    14. A toString method to print out the name in the form (First Middle Last)
    15. Write the definitions of the methods of the class Person to implement the operations for this class.
    16. Write a test program to test the above.
    This is what I have but I think I'm missing some of the above...also, my if...else statements aren't running the way I want.. '
    public class Person {
    private String firstName;
    private String lastName;
    private String middleName;
    public Person (String first, String middle, String last) {
    firstName = first;
    lastName = last;
    middleName = middle;
    public Person() {
    firstName = "";
    lastName = "";
    middleName = "";
    public String toString() {
    return (firstName + " " + middleName + " " + lastName);
    public void setFirstName(String first) {
    firstName = first;
    public void setMiddleName(String middle) {
    middleName = middle;
    public void setLastName(String last) {
    lastName = last;
    public String getFirstName() {
    return firstName;
    public String getMiddleName() {
    return middleName;
    public String getLastName() {
    return lastName;
    public boolean equals(Person otherPerson) {
    return (lastName.equals(otherPerson.lastName) && firstName.equals(otherPerson.firstName));
    public void makeCopy(Person otherPerson) {      
    lastName = otherPerson.lastName;
    middleName = otherPerson.middleName;
    firstName = otherPerson.firstName;
    public Person getCopy() {
    Person temp = new Person();
    temp.firstName = firstName;
    temp.lastName = lastName;
    temp.middleName = middleName;
    return temp;
    public Person(Person otherPerson) {
    firstName = otherPerson.firstName;
    middleName = otherPerson.middleName;
    lastName = otherPerson.lastName;
    public void printName() {
    System.out.println(firstName + "," + middleName + "," + lastName);
    } and the test program follows
    import java.util.Scanner;
    public class TestProgPerson {
       static Scanner console = new Scanner(System.in);
       public static void main(String[] args) {
          Person myName = new Person("Bill", "Andrew", "Johnson");
          Person yourName = new Person();
          String firstName;
          String middleName;
          String lastName;
          System.out.print("My Name: ");
          myName.printName();
          System.out.println();
          System.out.print("Your Name: ");
          yourName.printName();
          System.out.println();
          System.out.print("Enter your first, middle, and last name: ");
          firstName = console.next();
          middleName = console.next();
          lastName = console.next();
          System.out.println();
          yourName.setName(firstName, middleName, lastName);
          if (myName.equals(yourName))
          System.out.println("Both people are the same.");
          else
          System.out.println("The two people are not the same.");
          myName.setFirstName(firstName);
          myName.setMiddleName(middleName);
          myName.setLastName(lastName);
          System.out.print("My new name: ");
          myName.printName();
          System.out.println();
          yourName.makeCopy(myName);
          System.out.print("After copying myName into yourName, yourName: ");
          yourName.printName();
          System.out.println();
    }

    public class Person {
         private String firstName;
         private String lastName;
         private String middleName;
         public Person (String first, String middle, String last) {
              firstName = first;
              middleName = middle;
              lastName = last;
         public Person() {
              firstName = "";
              lastName = "";
              middleName = "";
         public String toString() {
              return (firstName + " " + middleName + " " + lastName);
         public void setName(String first, String middle, String last) {
              firstName = first;
              middleName = middle;
              lastName = last;
         public void setFirstName(String first) {
              firstName = first;
         public void setMiddleName(String middle) {
              middleName = middle;
         public void setLastName(String last) {
              lastName = last;
         public String getFirstName() {
              return firstName;
         public String getMiddleName() {
              return middleName;
         public String getLastName() {
              return lastName;
         public boolean equals(Person otherPerson) {
              return (firstName == otherPerson.firstName && middleName == otherPerson.middleName &&
                             lastName == otherPerson.lastName);
         public void makeCopy(Person otherPerson) {
              firstName = otherPerson.firstName;
              middleName = otherPerson.middleName;
              lastName = otherPerson.lastName;
         public Person getCopy() {
              Person temp = new Person();
              temp.firstName = firstName;
              temp.lastName = lastName;
              temp.middleName = middleName;
              return temp;
         public Person(Person otherPerson) {
              firstName = otherPerson.firstName;
              middleName = otherPerson.middleName;
              lastName = otherPerson.lastName;
         public void printName() {
              System.out.println(firstName + " " + middleName + " " + lastName);
    //Test Program for the above.
    import java.util.Scanner;
    public class TestProgPerson {
         static Scanner console = new Scanner(System.in);
         public static void main(String[] args) {
              Person myName = new Person("William", "Andrew", "Johnson");
              Person yourName = new Person();
              String firstName;
              String middleName;
              String lastName;
              System.out.print("My Name: ");
              myName.printName();
              System.out.println();
              System.out.print("Your Name: ");
              yourName.printName();
              System.out.println();
              System.out.print("Enter your first, middle, and last name: ");
              firstName = console.next();
              middleName = console.next();
              lastName = console.next();
              System.out.println();
              yourName.setName(firstName, middleName, lastName);
              if (myName.equals(yourName))
              System.out.println("Both people are the same.");
              else
              System.out.println("The two people are not the same.");
              myName.setFirstName(firstName);
              myName.setMiddleName(middleName);
              myName.setLastName(lastName);
              System.out.print("My new name: ");
              myName.printName();
              System.out.println();
              yourName.makeCopy(myName);
              System.out.print("After copying myName into yourName, yourName: ");
              yourName.printName();
              System.out.println();
    }

  • Total newbie needs help installing and setting up Solaris 10 as a server

    i'm attempting to set up one computer to act as a file and print server on my home network, so that i can store all of my music and video files on it instead and print to my parallel-only laser printer. 80% of the time i'm using my laptop, so i need the mass storage and printer to be handled by another device - the server!
    i'm not sure if i'm even installing Solaris 10 correctly. how should it be installed to then act as a server? my two (incredibly long, like 3+ hours each) install attempts so far have resulted in an OS that looks like a nice fancy GUI-laden desktop which doesn't appear to show me my 750G SATA storage drive (the OS is on a 40G IDE drive).
    in the end, i'd like to have the system working so that my only interaction with it is the power button - press it once to power it on and it'll boot up and long in automagically and make itself seen over the network (with printer and files stored on drives accessible to my laptop or any other PC that's on the same network), and then press the power button again to shut down the entire system gracefully (so far, when i press the power button, it's a quick kill like pulling the power cord - i'm pretty sure that's a bad way of having the system shut down, so how do i change it?)
    i'm really hoping to use Solaris due to the promising ZFS scheme. my only exposure so far to unix / linux has been with ubuntu, which i usually like but sometimes loathe (primarily file permissions and network manager).

    Let's try step by step rather than asking for setting up a server as a while and I'll try to help you as much as I can.
    For setting up a printer, it's not that easy or quick setting up a printer on Solaris, I mean it's not like plug-n-play. Tell us about your printer and how it's connected to your system (usb, ethernet, parallel, serial).
    As for shutting down the system, it's recommended to use the shutdown commnad like this:
    # shutdown -y -i0 -g0
    --gibb                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Getting error msg when trying to run 'weblogic.DDConverter', need help

    I'm getting the following error when I try to run the 'weblogic.DDConverter' program to convert a deployment descriptor for an EAR file currently running under WLS 8.1 (that needs to be migrated to WLS 9.2):
    [DDConverter] START Converting EAR CDMS.ear
    Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider
    javax.xml.stream.XMLInputFactory could not be instantiated: java.lang.Instantiat
    ionException
    at javax.xml.stream.XMLInputFactory.newInstance(Unknown Source)
    at weblogic.application.descriptor.BasicMunger2.<clinit>(BasicMunger2.ja
    va:76)
    at weblogic.application.ApplicationDescriptor$MyApplicationDescriptor.cr
    eateXMLStreamReader(ApplicationDescriptor.java:433)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescr
    iptorBean(AbstractDescriptorLoader2.java:369)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescrip
    torBeanWithoutPlan(AbstractDescriptorLoader2.java:720)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescrip
    torBean(AbstractDescriptorLoader2.java:729)
    at weblogic.application.ApplicationDescriptor.getApplicationDescriptor(A
    pplicationDescriptor.java:277)
    at weblogic.application.ddconvert.EarConverter.convertDDs(EarConverter.j
    ava:66)
    at weblogic.application.ddconvert.DDConverter.runBody(DDConverter.java:1
    57)
    at weblogic.utils.compiler.Tool.run(Tool.java:158)
    at weblogic.utils.compiler.Tool.run(Tool.java:115)
    at weblogic.application.ddconvert.DDConverter.main(DDConverter.java:177)
    at weblogic.DDConverter.main(DDConverter.java:10)
    Any ideas as to how to resolve this?
    Edited by aroc725 at 09/25/2007 1:19 PM

    Those slashes in the first line of the error message suggest to me that maybe you referred to a class incorrectly in your source code.

  • MP-BGP query need help

    Hi Experts,
    I've gone through so many mpls documents and I believe i have a decent grasp of how it works but applying those principles i appear to be stuck in a setup that just won't work.
    The setup is pretty straigh forward: R1 is connected to R2 and R2 is connected to R3.
    R1 has ospf peering with R2 and R2 has ospf peering with R3.
    OSPF working fine and connectivity via Lo on all routers working.
    R1 has MP-BGP bgp peering with R3 where R1 and R3 is advertising its Lo100 interface to each other.
    BGP working fine and I can see from R1 the Lo100 ip of R3 on the vrf myvrf routing table of R1.
    When I do a show ip route vrf myvrf on R1, route to Lo100 of R3 (99.1.1.3) has an egress of 5.1.1.3 (default global table).
    But when i try to ping from R1, 'ping vrf myvrf  99.1.1.3 source 99.1.1.1' ,  ping fails.
    Documentation says that this should work but apparently it doesn't for me; am not sure what i am missing here.
    I even tried to leak the route on both R1 and R3.  But still no go.
    R1:
    ip route vrf myvrf 5.1.1.3 255.255.255.255 f0/0 1.1.1.2
    R3:
    ip route vrf myvrf 5.1.1.1 255.255.255.255 f0/0 2.1.1.1
    Don't know what i am doing wrong here.  And to be honest am getting confused.  Please help.
    Setup is as follows:
    R1:
    int f0/0
    ip 1.1.1.1 255.255.255.0
    mpls ip
    int Lo0
    ip add 5.1.1.1
    int Lo100
    ip vrf forwarding myvrf
    ip add 99.1.1.1 255.255.255.255
    ip vrf myvrf
    rd 10:20
    route-target both 10:20
    router ospf 1
    router-id 5.1.1.1
    network 1.1.1.0 0.0.0.255 area 0
    network 5.1.1.3 0.0.0.0.0 area 0
    router bgp 10
    neighbor 5.1.1.3 remote-as 10
    no neighbor 5.1.1.3 active
    neighbor 5.1.1.3 update-source Lo0
    address-family vpnv4
    neighbor 5.1.1.3 activate
    neighbor 5.1.1.3 send-community both
    address-family ipv4 vrf myvrf
    network 99.1.1.1 mask 255.255.255.255
    R2:
    int f0/0
    ip add 1.1.1.2 255.255.255.0
    mpls ip
    int f1/0
    ip add 2.1.1.1 255.255.255.0
    mpls ip
    int Lo0
    ip add 5.1.1.2 255.255.255.0
    router ospf 1
    router-id 5.1.1.2
    network 1.1.1.0 0.0.0.255 area 0
    network 2.1.1.0 0.0.0.255 area 0
    network 5.1.1.2 0.0.0.0 area 0
    R3:
    int f0/0
    ip add 2.1.1.2 255.255.255.0
    mpls ip
    int Lo0
    ip add 5.1.1.3 255.255.255.0
    int Lo100
    ip vrf forwarding myvrf
    ip add 99.1.1.3 255.255.255.255
    router ospf 1
    network 2.1.1.0 0.0.0.255 area 0
    network 5.1.1.2 0.0.0.0 area 0
    router bgp 10
    neighbor 5.1.1.1 remote-as 10
    no neighbor 5.1.1.1 activate
    neighbor 5.1.1.1 update-source Lo0
    address-family vpnv4
    neighbor 5.1.1.3 activate
    neighbor 5.1.1.3 send-community both
    address-family ipv4 vrf myvrf
    network 99.1.1.3 mask 255.255.255.255

    Hello Marcusbrutus,
    blau grana is right you have an issue with loopback addresses subnet masks.
    Your control plane looks like fine because you have all the expected MP BGP VPNv4 routes in place, but the forwarding plane is broken.
    MPLS L3 VPN packets are sent within the LSP with destination the remote PE loopback address so from R1 point of view is R3's L0.
    If you go on R2 device and you check the state of MPLS forwarding for R3 L0 IP address you will see that instead of seeing a POP TAG action you will see an untagged action.
    The reason for the wrong LSP binding is the subnet mask on R3 loopback address:  OSPF advertises all loopback addresses with a /32 mask by default, but the subnet mask is different. LDP carries the configured subnet mask. But installation of labels is made after check with IGP (OSPF in this case).
    As a result of this the R2 router cannot install the correct POP TAG  = implicit null label as action to do to reach R3 L0.
    With POP TAG  action the R2 router removes the external label  (POP a label) and sends a packet (with MPLS ethertype on ethernet) with a single label MPLS stack to the egress PE R3. R3 sees a label associated to the VRF and it is able to route the packet to the appropriate interface.
    With untagged action R2 removes a label take all the packet content and sends it as it was an IP packet to the downstream device. (with ethertype 0x800 on ethernet) The downstream device finds a packet that is supposed to be an IP packet but it isn't (for the inner label still there) and silently drops it.
    This is what we had seen in lab tests.
    To solve this issue you should:
    use /32 loopback addresses this the recommended best practice
    or you can still use non overlapping non /32 loopback addresses but you need to add the command ip ospf network point-to-point under loopback configuration as this makes OSPF to advertise the true IP subnet mask
    Hope to help
    Giuseppe

Maybe you are looking for