Application of average time

I hope that I have defined my problem definition correctly and the formatting is not lost.

I have two tables table 1 and table 2

Table 1

AcName TID MIDDLE LTime $vdate

AAA 123 777 11/01/15 03:00 11/01/15

AAA 456 777 01/11/15 15:00 11/01/15

BBB 789 888 11/01/15 04:00 11/01/15

CCC 990 999 11/01/15 18:00 11/01/15

BBB 880 888 01/11/15 05:00 11/01/15

DDD 770 666 01/11/15 05:00 11/01/15

BBB 555 444 11/01/15 13:00 11/01/15

TID is primary key

ENVIRONMENT can be the same for both records in max

Table 2

MTime TXID

123, 11/01/15-17:00

456 01/11/15-17:00

789 11/01/15 06:00

770 11/01/15-10:00

990 11/01/15 20:00

880 11/01/15 06:00

555 11/01/15-15:00

TXID is a foreign key on table 1 TID

I need a query that gives the average time required for a given such as Acname

For a given MID take the min (LTime) to make it unique.

AvgTime for Acname = sum of all (MTime - min (LTime)) / Total number

Required output

-----------------------

Name AvgTime(MTime-LTime) in hours

AAA 2

BBB 1.5

REC 2

DDD 5

with

Table1 as

(select 'AAA' acname, 123 tid, 777 mid, to_date (11 January 15 03:00 "," yy-mm-dd HH24 ') ltime, to_date('01-11-15','mm-dd-yy') union $vdate double all the)

Select 'AAA', 456, 777, to_date (January 11, 15 15:00 ',' dd-mm-aa hh24:mi'), to_date('01-11-15','mm-dd-yy') of all double union

Select 'BBB', 789, 888, to_date (11 January 15 04:00 ',' dd-mm-aa hh24:mi'), to_date('01-11-15','mm-dd-yy') of all double union

Select "CCC", 990, 999, to_date (11 January 15 18:00 ',' dd-mm-aa hh24:mi'), to_date('01-11-15','mm-dd-yy') of all double union

Select 'BBB', 880, 888, to_date (11 January 15 05:00 "," dd-mm-aa hh24:mi'), to_date('01-11-15','mm-dd-yy') of all double union

Select 'DDD', 770, 666, to_date (11 January 15 05:00 "," dd-mm-aa hh24:mi'), to_date('01-11-15','mm-dd-yy') of all double union

Select 'BBB', 555, 444, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi'), to_date('01-11-15','mm-dd-yy') of the double

),

Table2 as

(select txid 123, to_date (January 11, 15 17:00 "," yy-mm-dd HH24 ') mtime of union double all the)

Select 456, to_date (January 11, 15 17:00 "," yy-mm-dd HH24 ') union double all the

Select 789, to_date (11 January 15 06:00 "," yy-mm-dd HH24 ') union double all the

Select 770, to_date (11 January 15 10:00 "," yy-mm-dd HH24 ') union double all the

Select 990, to_date (11 January 15 20:00 "," yy-mm-dd HH24 ') union double all the

Select 880, to_date (11 January 15 06:00 "," yy-mm-dd HH24 ') union double all the

Select 555, to_date (January 11, 15 15:00 "," yy-mm-dd HH24 ') of double

)

Select acname, avg (hrs)

from (select distinct t1.acname, t1.mid,

(t2.mtime - max (t1.ltime) over (partition by order t1.mid by zero rows between unbounded preceding and following unbounded)) * 24 hrs

FROM table1 t1,

table2 T2

where t1.tid = t2.txid

)

Acname group

order of acname

ACNAME AVG(HRS)
AAA 2
BBB 1.5
CCC 2
DDD 5

Concerning

Etbin

Tags: Database

Similar Questions

  • Open an application at a time

    If I was playing in a Terminal on my MacBook Air, and I stumbled upon a way to make sure I can open only one application at a time. I used this command: write com.apple.dock single-app - bool true killall Dock. Now so-called all I have to do is switch 'true' to false. But when I do that, it does not change this back to normal. If you could tell me how I can fix this I would REALLY appreciate it!

    defaults delete com.apple.dock single-app; Killall Dock

  • Is any application of Benchmarking available in FFOS? Basically, I want to compare the performance as 'time to load application', "Image load time", etc.

    I'm basically performing team. Working in porting gecko 1.2. We did successfully porting. But we believe that it is not as big as gecko 1.1 performance. If we want any tool/app to measure performance.
    (1) application of loading time
    (2) time of image rendering
    (3) audio integrated
    (4) key response time
    (5) browser, loading time
    etc.

    Hello

    Thank you for your interest in Firefox OS. In the application settings click the device information > more information > developer. You will find tools for dev for load time, frames per second, etc.

    Best regards
    Michelle Luna

  • iPad will not update - will be only update one application at a time

    I have a curious problem. Recently, I noticed that I have available updates for applications all the time that have not been downloaded. I see a red circle with a number on my App Stpre app - this didn't use to be the case because the iPad would be updated automatically.

    If I go to the App Store manually and hit all the updates on the updates page waiting all the buttons update app turn to the circle download for a minute and then just go back to update buttons. Nothing is updated.

    Here's the first twist:

    If I try to update by using the UPDATE of each unique application, it will work as long as I don't need to update the application at the top of the list.

    This is the second twist:

    If I update all apps agree only a first, then I remove that first, the next time that the iPad gets new updates to download the top app will get stuck again (some app is) and I have to go and manually update again. So it doesn't seem to be the result of an individual 'bad app.

    Anyone know what I can do to try to get my iPad to begin the auto process

    It's one of the most bizarre App Store update problems I've seen in a while. I guess you trid steps basic troubleshooting, but just in case you don't have it, try the following steps and do them in this order.

    Force close the App Store App. Press twice the House quickly. You will see small glimpses of your applications recently used. Swipe to find the app store App shot upward on the overview of the application to close.

    Next force restart the iPad. No data is affected by this. To force the reboot your device, press and hold the two buttons of sleep/wake and home for at least ten seconds, until you see the Apple logo.

    If this does not help, try this. Reset all the settings. You won't lose any data, but most of the settings of the device will have to be entered again in the settings app. This includes passwords for WiFi network, paper settings painted. SIri, privacy settings, etc.. Settings > general > reset > reset all settings.

    If all else fails, you can restore the iOS software. Backup your iPad before you restore, and then restore the backup when you are finished. If this doesn't always help, restore your iPad like new and all over again. Most bought content can be downloaded again free of charge as long as you use the same ID Apple and as long as the content is always available in the store.

    Restore iPad to factory settings

    http://support.Apple.com/kb/ht1414

    Download last purchases

    http://support.Apple.com/kb/ht251

    Restore factory settings may seem exaggerated, but it could end up being what you need to do to finally solve the problem.

  • Cannot use the calendar network unavailable or slow app. The application takes more time to load than expected.

    When you use iCloud on my iMac I get the message "network unavailable or slow. The application takes more time to load than expected. "This has been the case for several hours, but other applications I use (Mail, Contacts, Notes, reminders), all seem to work well.  The

    I have the same message when I try to load the reminders in iCloud. All other applications work correctly. This issue has been ongoing for about a month now.

    Have this problem on my work computer running Windows 7 SP1 Pro and Macbook Air late 2009 w / OS X 10.11

  • Deploy an application in real time

    Hello, I want to create an application to deploy the application in real time (previously compiled) in a Compact RIO goal. My goal: a standard user could deploy the new application without LabVIEW Real-time... Will he something exists? Thank you

    Hello again,

    Even if you don't have a USB port, I posted the link because there are screws that could possibly be used.

    I also found that you can use the example of "Browser FTP" VI in order to copy files to your cRIO. The next step is to create an executable from this example.

    Kind regards

  • @ start up, I get a box that says microsoft visual c ++ Runtime library... this application has requested time to close in an unusual way

    On startup, I get a box that says microsoft visual c ++ runtimelibrary... this application has requested time to close in an unusual way... I click on OK, but after several minutes of "Please wait", the same pop mailbox and I can't log on to my laptop.  It started after a windows update that I did.  Once in a while, if I stop the computer laptop and reboot, I'll only get this box once and then it will allow me to connect and everything is fine after that.

    Hello

    Step 1:

    You can try to start in safe mode and check if the problem persists. Only basic files and drivers needed to run Windows are started. If a problem doesn't reappear when you start in safe mode, you can eliminate the default settings and basic as possible cause device drivers. To start in safe mode follow the link.

    http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode

    Step 2:

    If the problem does not occur in safe mode then boot to the desktop in normal mode and check that the third-party program is causing the problem. To configure your computer to clean boot follow the link below.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    Note: When you are finished troubleshooting, follow step 7 article to start on normal startup.

    Hope that information was useful

  • Average time for portable computer defragmentation Vista

    What is the average time to defragment my laptop? 3 hours?

    * original title - what is the average time to defragment my laptop? 3 hours? *

    There is no time limit for this.

    Depends on number of files, etc. on your computer, using the same, etc, etc.

    If you want to watch and keep track of what he does, use this:

    http://www.SnapFiles.com/reviews/Auslogics-Disk-Defrag/adiskdefrag.html

    Auslogics Disk Defrag is a disk defragmentation tool that supports FAT 16, FAT 32, and NTFS volumes. It defragments supply with demand automatic defrags when your system is idle and advanced options to customize the files that will be défragmentées

    See you soon.

    Mick Murphy - Microsoft partner

  • Show the average time in days hours minutes seconds

    Hello

    I have two tables as follows,

    Is it possible to separate the average time in days, hours, minutes, seconds.

    I need the average time required for each account.

    with
    Table1 as
    (select "AAA" acname, 123 tid, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') ltime Union double all the )
    Select 'AAA', 456, to_date (January 11, 15 15:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
    Select 'BBB', 789, to_date (11 January 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
    Select 'CCC', 990, to_date (11 January 15 18:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
    Select 'BBB', 880, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
    Select 'DDD', 770, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
    Select 'BBB', 555, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double
    ),
    Table2 as
    (select txid 123, to_date (January 11, 15 14:00 ',' dd-mm-aa hh24:mi:ss') mtime of union double all the )
    Select 456, to_date (January 11, 15 16:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
    Select 789, to_date (11 February 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
    Select 770, to_date (11 February 15 07:00 "," dd-mm-yy hh24:mi:ss') of all the double union
    Select 990, to_date (11 January 15 23:30 ',' mm-dd-aa hh24:mi:ss') of all the double union
    Select 880, to_date (11 February 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
    Select 555, to_date (11 February 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double
    )
    Choose acname, avg (hrs)
    from (select distinct t1.acname, (t2.mtime - t1.ltime) * 24 h )
    from table1 t1,
    Table2 t2
    where t1.tid = t2.txid
    )
    Group acname


    Expected results


    ACNAME Avg (day) APR (hrs) Avg (Mins) Avg (dry)

    AAA 0 1 0 0 (that is to say 14:00-13:00 = 1 and 16 15 = 1, Avg = (1 + 1) / 2 = 1)

    BBB          1               0          0               0

    CCC          0               5          30             0

    DDD          1               2          0               0

    with

    Table1 as

    (select 'AAA' acname, 123 tid, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') ltime Union double all the)

    Select 'AAA', 456, to_date (January 11, 15 15:00 ',' dd-mm-aa hh24:mi:ss') of all the double union

    Select 'BBB', 789, to_date (11 January 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union

    Select "CCC", 990, to_date (11 January 15 18:00 ',' dd-mm-aa hh24:mi:ss') of all the double union

    Select 'BBB', 880, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union

    Select 'DDD', 770, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union

    Select 'BBB', 555, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double

    ),

    Table2 as

    (select txid 123, to_date (January 11, 15 14:00 ',' dd-mm-aa hh24:mi:ss') mtime of union double all the)

    Select 456, to_date (January 11, 15 16:00 ',' dd-mm-aa hh24:mi:ss') of all the double union

    Select 789, to_date (11 February 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union

    Select 770, to_date (11 February 15 07:00 "," dd-mm-yy hh24:mi:ss') of all the double union

    Select 990, to_date (11 January 15 23:30 ',' mm-dd-aa hh24:mi:ss') of all the double union

    Select 880, to_date (11 February 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union

    Select 555, to_date (11 February 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double

    )

    Select acname,

    trunc (AVG (Days)) days,

    trunc (mod (AVG (Days), 1) * 24) hours,

    trunc (mod (AVG (Days) * 24.1) * 60) minutes.

    trunc (mod (AVG (Days) * 24 * 60.1) * 60) seconds

    from (select distinct t1.acname,(t2.mtime-t1.ltime) days

    FROM table1 t1,

    table2 T2

    where t1.tid = t2.txid

    )

    Acname group

    /

    ACN DAYS HOURS MINUTES SECONDS

    --- ---------- ---------- ---------- ----------

    BBB         31          0          0          0

    CCC          0          5         30          0

    AAA          0          1          0          0

    DDD         31          1          0          0

    SQL >

    SY.

  • Average time of recovery in the alerts log

    Hi Experts,

    I found the following statement in the alerts log. my version of the 11.2.0.2.0 database - 64 bit.

    FAST_START_MTTR_TARGET 60 is too low, to the minimum achievable MTTR 61 rather helps - in my alertlog.

    I have found that whenever you set fast_start_mttr_target to a value other than zero, and while the MTTR is what WE, Oracle Corporation recommends that you disable (value 0) the following parameters:

    LOG_CHECKPOINT_TIMEOUT

    LOG_CHECKPOINT_INTERVAL

    FAST_START_IO_TARGET

    The values that I found in my database.

    fast_start_mttr_target integer 60

    log_checkpoint_interval integer 100000

    log_checkpoint_timeout around 1200

    FAST_START_IO_TARGET integer 0

    My question is will I have to perform no action, what I found in the alerts log. I read on the fast_start_mmtr_target according to my understanding

    The fast_start_mttr_target defines the average time effective to the target for recovery (MTTR), expressed in seconds.

    The default value of fast_start_mttr_target is 300 seconds (5 Minutes). and the maximum we can give 3 600 (1 hour).

    Administrators specify a (delimited) target time to complete the phase of recovery of cache recovery with the fast_start_mttr_target initialization parameter.

    Please suggest your ideas.

    Thanks in advance.

    Without knowing why, this parameter has been set to a specific value (in this case 60), I suggest you not change to something else. In general, the init.ora parameters are defined for some reason, I hope that logic.

    HTH
    Srini

  • Find the average time required to process an order?

    Hello

    I followed four tables.
    /* There are other columns as well but just using the relevent columns.*/
    
    CREATE TABLE COMPANY_ORDERS
    (
      INTERNALORDERID            NUMBER(10)         NOT NULL,
      ORDERENTRYDATE             DATE,
      SYSTEMID             NUMBER(10)
    )
    
    /* There are other columns as well but just using the relevent columns.*/
    /* The data in archive table goes after each three months.*/
    CREATE TABLE COMPANY_ORDERS_ARCH
    (
      INTERNALORDERID            NUMBER(10)         NOT NULL,
      ORDERENTRYDATE             DATE,
      SYSTEMID             NUMBER(10)
    )
    
    /* There are other columns as well but just using the relevent columns.*/
    CREATE TABLE COMPANY_ORDER_HISTORY
    (
      INTERNALORDERID   NUMBER(10)                  NOT NULL,
      ITEMORDER         NUMBER(10)                  NOT NULL,
      ENTRYDATE         DATE                        NOT NULL,
      UPDATEDATE        DATE,
      STATUSID          NUMBER(10),
      INTERNALSTATUSID  NUMBER(10)
    )
    /* The data in archive table goes after each three months.*/
    CREATE TABLE COMPANY_ORDER_HISTORY_ARCH
    (
      INTERNALORDERID   NUMBER(10)                  NOT NULL,
      ITEMORDER         NUMBER(10)                  NOT NULL,
      ENTRYDATE         DATE                        NOT NULL,
      UPDATEDATE        DATE,
      STATUSID          NUMBER(10),
      INTERNALSTATUSID  NUMBER(10)
    )
    The data in TABLE COMPANY_ORDER_HISTORY or COMPANY_ORDER_HISTORY_ARCH of the TABLE can be used as below:
    SET DEFINE OFF;
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179058, 8, TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), 7, 1360);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179058, 10, TO_DATE('08/03/2009 11:42:16', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:42:16', 'MM/DD/YYYY HH24:MI:SS'), 7, 1430);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179180, 1, TO_DATE('08/03/2009 10:21:30', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 10:21:30', 'MM/DD/YYYY HH24:MI:SS'), -3, -3);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179180, 3, TO_DATE('08/03/2009 10:25:06', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 10:25:06', 'MM/DD/YYYY HH24:MI:SS'), 0, 0);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179180, 14, TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), 7, 1360);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179180, 16, TO_DATE('08/03/2009 11:42:17', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:42:17', 'MM/DD/YYYY HH24:MI:SS'), 7, 1430);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179184, 1, TO_DATE('08/03/2009 10:21:33', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 10:21:33', 'MM/DD/YYYY HH24:MI:SS'), -3, -3);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179184, 3, TO_DATE('08/03/2009 10:25:09', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 10:25:09', 'MM/DD/YYYY HH24:MI:SS'), 0, 0);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179184, 14, TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), 7, 1360);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179184, 16, TO_DATE('08/03/2009 11:42:18', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:42:18', 'MM/DD/YYYY HH24:MI:SS'), 7, 1430);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179185, 1, TO_DATE('08/03/2009 10:21:33', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 10:21:33', 'MM/DD/YYYY HH24:MI:SS'), -3, -3);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179185, 3, TO_DATE('08/03/2009 10:25:09', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 10:25:09', 'MM/DD/YYYY HH24:MI:SS'), 0, 0);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179185, 14, TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:40:00', 'MM/DD/YYYY HH24:MI:SS'), 7, 1360);
    Insert into COMPANY_ORDER_HISTORY
       (INTERNALORDERID, ITEMORDER, ENTRYDATE, UPDATEDATE, STATUSID, INTERNALSTATUSID)
     Values
       (8179185, 16, TO_DATE('08/03/2009 11:42:17', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/03/2009 11:42:17', 'MM/DD/YYYY HH24:MI:SS'), 7, 1430);
    COMMIT;
    Every day an order number is raised through different systems (identified by COMPANY_ORDERS. SYSTEMID). Now I need to find a day average time an order made, by SYSTEMID to reach a final statusid 7 (x), internalstausid 1430 (y) of his first entrytime in COMPANY_ORDER_HISTORY (IE for an orderid, the first entry of COMPANY_ORDER_HISTORY founded in updatedate or for an orderid, or the entrytime for an orderid when ITEMORDER = 1)

    Tables of archive can be reunited if the fake of the length of the period for which the order is archived.

    Another desired suggestion is table archive is very large.
    It will be appropriate to create a materialized view archived table, not seen that data last month and then join the Materialized view query (since the statistics must be shown to last a year...)?

    Concerning

    Published by: a R on October 28, 2009 06:02

    Published by: a R on October 28, 2009 14:13

    Hello

    First, initialize variables bind using some PL/SQL like this:

    -- These parameters are passed by the user:
    VARIABLE  p_statusid          NUMBER
    VARIABLE  p_internalstatusid     NUMBER
    VARIABLE  p_start_date          VARCHAR2 (10)
    VARIABLE  p_end_date          VARCHAR2 (10)
    
    -- These parameters are derived from the ones that are passed:
    VARIABLE  p_date_trunc          VARCHAR2 (10)
    VARIABLE  p_need_arch          NUMBER
    
    DECLARE
           end_date     DATE;
           start_date     DATE;
    BEGIN
           :p_statusid     := 7;
           :p_internalstatusid     := 1430;
           :p_start_date := '03/08/2009';
           :p_end_date   := '04/08/2009';
    
           start_date := TO_DATE (:p_start_date, 'DD/MM/YYYY');
           end_date   := TO_DATE (:p_end_date,   'DD/MM/YYYY');
    
    --       The following parameters could be computed in the query, but it's messier
    
           :p_date_trunc := CASE
                        WHEN  end_date - start_date <= 1
                        THEN  'HH'
                        WHEN  MONTHS_BETWEEN (end_date, start_date) <= 1
                        THEN  'DD'
                        WHEN  MONTHS_BETWEEN (end_date, start_date) <= 6
                        THEN  'IW'
                        ELSE  'MM'
                         END;
    
           :p_need_arch := CASE
                        WHEN  start_date > ADD_MONTHS (SYSDATE, -4)
                        THEN  0       -- dates are all within last 4 months, archive tables are not needed
                        ELSE  1       -- some dates are older than 4 months ago, archive tables are needed
                              END;
    END;
    /
    

    You don't absolutely have to do that, but it made the query much shorter and cleaner.

    The query itself is:

    WITH       dop     AS
    (
         SELECT     systemid,     internalorderid
         FROM     company_orders
         WHERE     orderentrydate >= TO_DATE (:p_start_date, 'DD/MM/YYYY')
         AND     orderentrydate <  TO_DATE (:p_end_date,   'DD/MM/YYYY') + 1
              --
         UNION ALL
                 --
         SELECT     systemid,     internalorderid
         FROM     company_orders_arch
         WHERE     orderentrydate >= TO_DATE (:p_start_date, 'DD/MM/YYYY')
         AND     orderentrydate <  TO_DATE (:p_end_date,   'DD/MM/YYYY') + 1
         AND     :p_need_arch   = 1
    )
    ,     coh     AS
    (
         SELECT       internalorderid
         ,       MIN ( CASE
                            WHEN  itemorder     = 1
                      THEN      entrydate
                      END
                    )          AS h1_entrydate
         ,       MAX ( CASE
                            WHEN  internalstatusid     = :p_internalstatusid
                      AND      statusid           = :p_statusid
                      THEN      entrydate
                      END
                    )          AS hn_entrydate
         FROM       company_order_history
         WHERE       entrydate     >= TO_DATE (:p_start_date, 'DD/MM/YYYY')
         GROUP BY  internalorderid
                      --
         UNION ALL
                      --
         SELECT       internalorderid
         ,       MIN ( CASE
                            WHEN  itemorder     = 1
                      THEN      entrydate
                      END
                    )          AS h1_entrydate
         ,       MAX ( CASE
                            WHEN  internalstatusid     = :p_internalstatusid
                      AND      statusid           = :p_statusid
                      THEN      entrydate
                      END
                    )          AS hn_entrydate
         FROM       company_order_history_arch
         WHERE       entrydate     >= TO_DATE (:p_start_date, 'DD/MM/YYYY')
         AND       :p_need_arch     = 1
         GROUP BY  internalorderid
    )
    SELECT       dop.systemid
    ,       AVG (coh.hn_entrydate - coh.h1_entrydate)     AS avereagetime
    ,       TO_CHAR ( TRUNC (coh.hn_entrydate, :p_date_trunc)     --  + (1 / 24)
                  , 'MM/DD/YYYY' || CASE
                             WHEN  :p_date_trunc = 'HH'
                             THEN  ' HH24:MI:SS'
                                END
                )     AS periodstartdate
    FROM       dop
    JOIN       coh     ON     coh.internalorderid     = dop.internalorderid
    GROUP BY  dop.systemid
    ,       TRUNC (coh.hn_entrydate, :p_date_trunc)
    ORDER BY  dop.systemid
    ,            TRUNC (coh.hn_entrydate, :p_date_trunc)
    ;
    

    The conditions

         AND     :p_need_arch   = 1
    

    should "short-circuit" queries on the archived tables when it comes from kniown, the: parameter of p_start_date, that they are not necessary.

    The coh subquery matches your original of subqueries h1 and h2. It is more effective to go through the tables only once. The WHERE clause in coh contain the conditions common to h1 and h2; conditions that apply only to the h1 or h2 are transferred in CASE expressions.

    You always want to group by a date that is truncated. According to the: p_strart_date to: p_end_date Beach, you can truncate the next time down, day, week or month. the only difference is the 2nd argument to the TRUNC function.
    When you group by weeks, I used the ISO weeks, which begin Monday and end on Sunday. If you need a different kind of week, it's a little more complicated.

  • How to check the "average time WAITED.

    I find huge "log file sync" v$ session events.
    and I want to check the «average time waited to review»
    but where and how to find the total "wait time" event? (time waited way = time / waiting time)

    Query V$ SYSTEM_EVENT where event = "synchronize file journal." However, this gives you cumulative statistics (TIME_WAITED, TIME_WAITED_MICRO, TOTAL_WAITS, AVERAGE_WAIT) since the Instance was started.

    For hourly statistics, look at the AWR reports, if you Pack diagnosis.

    (Or write your own scripts to retrieve v $ SYSTEM_EVENT and compare the numbers every hour)

  • Search application restore in Time Machine is empty

    I was looking for in Time Machine to restore an earlier version of Pages, but when I opened the time Machine in the Applications section is empty. Other files (Documents, downloads) watch the content, but only applications have nothing to show. What is problem?

    Thank you

    Two possibilities:

    (1) requests have been excluded from Time Machine backups. Check Time Machine preferences / Options to ensure that Applications are not on the list of excluded items of backups.

    (2) Time Machine is defective. The operating system will need to be reinstalled, since Time Machine is a part of Mac OS X.

  • cRIO: error when compiling an application in real time

    My code can be executed when the cRIO is connected to the PC with Ethernet cable.

    But when I want to compile my code (Release), I get the following massage.

    Also the image of the massage is shown below.

    ////////////////////////////////////

    Visit ni.com/ask support request page to learn more about the resolution of this problem. Use the following as a reference:

    Error 6 took place to copy in AB_Targetfile.lvclassostBuild.vi-> AB_Application.lvclassostBuild.vi-> AB_Engine_Build.vi-> AB_Build_Invoke.vi-> AB_Build_Invoke.vi.ProxyCaller

    Possible reasons:

    LabVIEW: File generic i/o error.

    E:\2013_05_23a_research\2013_05_27a_Richard's\exercise\2013_07_07_exampleFinder_1DMAFIFO\examples\CompactRIO\Module Specific\NI 9234\builds\NI 9234 is Started\NI-cRIO9024-UConn\My in time real Application\c

    ////////////////////////////////////

    Hi Cashany,

    What version of LabVIEW Real-time work? What cRIO you deploy? What version of the Drivers OR-RIO do you use?

    Behind your error dialog box you have a save warning dialog box. What is the full path of ANTICIPATED LabVIEW expects to find this VI to? Have you tried to correct this conflict by moving the file to the intended path or change your project for what he expect from this new path?

    I also note that the listed pathnames are rather long. It is possible that your problem is related to this knowledge base, error 6 occurs to create folder when I build my executable in real time?

  • Quit the Application in real time

    Is it possible to leave a real-time application of in the software (the exit() function reboots the system according to the documentation) without the system rebooting?

    Thank you

    Martin

    The only safe way to complete a CVI RT application is to return from the function RTMain. If you are very deeply nested under RTMain when you want to complete the application, and it is not practical to place battery completely upward, then an option you have is to use setjmp/longjmp functions to jump up to RTMain.

    If you do not skip a bunch of code of long jump, you must always be very careful in making sure you release/close all handles or other memory resources that your application may have acquired, before leaving. Unlike Windows, the RT process unique operating system and the process will continue to run after your application exits, so whatever you do in an invocation will persist.

    Luis

Maybe you are looking for