subtract the sum of the times of highest level duration

I have a table defined as follows:

CREATE TABLE EVENT
(
REQUEST_ID varchar2 (100),
CODE_RANGE varchar2 (40),
TERM decimal (12)
);

The values of 'CODE_RANGE' can be 'publicEntryPoint' or 'webServiceCall '. A line with CODE_RANGE of 'publicEntryPoint' shows how long a service API call high level taken. A line with a CODE_RANGE of "webServiceCall" and the same REQUEST_ID value as a line with CODE_RANGE of 'publicEntryPoint' represents a web service call that was called inside this method of public entry point. In theory, there could be more than one line of "webServiceCall" with the same REQUEST_ID value. Finally, there may be other possible values of the CODE_RANGE, but they will represent all the cooks 'code' inside the public entry point method or methods that he calls.

Do I have to build is a query that makes account of the duration of each public entrance point, but by subtracting the sum of the values of all other rows with the same value request_id and CODE_RANGE! = "publicEntryPoint".

For example, with the following lines:
'1': 'publicEntryPoint': 12
'1': 'webServiceCall': 3
'1': 'webServiceCall': 2


I would get the top level of the '12' value, but also the value of '7', 12-3-2.

Published by: david.karr on July 19, 2010 11:35

Something like:

with event as (
               select '1' request_id,'publicEntryPoint' code_range,12 duration from dual union all
               select '1','webServiceCall',3 from dual union all
               select '1','webServiceCall',2 from dual
              )
select  request_id,
        code_range,
        duration,
        case code_range
          when 'publicEntryPoint' then duration * 2 - sum(duration) over(partition by request_id)
          else duration
        end actual_duration
  from  event
/

R CODE_RANGE                        DURATION           ACTUAL_DURATION
- ---------------- ------------------------- -------------------------
1 publicEntryPoint                        12                         7
1 webServiceCall                           2                         2
1 webServiceCall                           3                         3

SQL> 

SY.

Tags: Database

Similar Questions

  • now subtract the time constant of the stamp

    I thought it would be easy.

    I was expecting "Subtracted the time" to display the difference between "Fixed time" and "currently".

    While it of countdown minutes and seconds as planned, the hours indicator is several hours off the coast of the expected value.

    The date "subtracted the time' is 1903, so it's time zero stamping.

    So basically, how can I get the patch for montrer.sss?

    Here are some of the things I've tried:

    I tried the 24-hour format. I have tried most every properties button.

    I tried to adjust the indicator "Subtracted the time" relative time in the properties. But I had two problems related to the definition of this property.

    In 'Default Edit Mode', the selections of absolute time and Relative are grayed out. So I couldn't change it, if absolute time was that all two blue grayed out and highlighted.

    Then I switched to "Advanced Editing Mode", played with the format of time codes Relative, absolute and digital and all that seemed to be getting was a red LED when I tried different combinations of "Insert into String Format". I had to go back to 99% of the time. When I don't have no 'come back' it made no difference in the result.

    Do not use a timestamp indicator.  Use a regular digital indidcator and set the display of relative time format.

  • By subtracting the time in the time display

    Hello

    When I want to add time to display the time for re - move the cursor to the timeline, I use + 15 for example. But when I want to shorten, wouldn't work no - 15. How frames subtraction both display work?

    http://files.2he.com/uploads2/2014_02_05_16_41_52.jpg

    Kind regards

    Frank

    After Effects help:

    http://helpx.Adobe.com/after-effects/using/previewing.html#move_the_current_time_indicator _cti

    "To move forward some time or number of frames, click the display of the moment and then enter a plus sign (+) followed by the timecode or number of frames to advance." For example, enter + 20 to go forward 20 images or 01:00 to go forward one second. Precede the value with the sign (-) to go back. For example, enter +-20 to go backward 20 frames or + - 1:00 to go back a second. »

  • the sum of the time of loop iteration.

    Hello

    I need to estimate a time every time through the loop. The time is different (depending on the counter triggers). I need to estimate the time of each simple iteration and add the last time with the current iteration. For example the first iteration - 400ms, second time 350 ms (400 + 350) (, third 380 (400 + 350 + 380) Ms. I tried with check meter and register shift, but I got a sum of (absolute) the tick counter.) I will be grateful for any suggestion. I need at this point to draw the graph with measured values.

    Lukasz

    Hi Lukas.

    your question looks like a perfect example to learn how to use the shift registers. Is - this work at home?

    (With the help of a random wait for testing...)

  • Subtract the model image of a real-time video and image/video subtracted from output

    Hi all

    I have a case in which I need to acuiqre a video (of circular loop) to a camera (which I am able to do with the vision development module in avi format) and subtract the model standard (for loop) image of him and display the output for each frame subtraction. The subtraction will tell me how much movement there was in the loop in real time. Is it possible to do?

    I donot want to save any image or video, just want to show the subtraction of real time to the user

    Joined the image.not still able to add video

    Hello AnkitG,

    Subtract the IMAQ VI removes one image from another or a constant. You can then view the removal from the user or save the images if necessary. Here a link to the reference IMAQ subtract VI.

  • Find the period by subtracting the start time and end

    Version: 11.2

    I am not a SQL expert.

    I'm trying to subtract the start and end time and find the difference between these two times.

    In the example below, the difference between the value of start_time and end_time is approximately 52 minutes (18:15 to 19:07)

    I tried a few tricks to find the difference below. But it did not work.

    SQL > create table t (start_time date, date of end_time);

    Table created.

    SQL > desc t

    Name                                                              Null?    Type

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

    START_TIME                                                                 DATE

    END_TIME                                                                   DATE

    SQL > insert into values t (to_date (24 June 2013 18:15:42 ',' DD/MONTH/YYYY HH24:MI:SS'), to_date (24 June 2013 19:07:54 ',' DD/MONTH/YYYY HH24:MI:SS'));))

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL >

    SQL >

    SQL > select * from t;

    START_TIME, END_TIME

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

    24 June 2013 18:15:42 24 June 2013 19:07:54

    -Trying to find the difference of Start_Time and End_Time

    SQL > select end_time-start_time in t;

    END_TIME-START_TIME

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

    . > 03625 than signifie.03625?

    -More than failure tent

    SQL > select to_number(end_time-start_time)/60 t.

    TO_NUMBER(END_TIME-START_TIME)/60

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

    .000604167

    SQL > select to_number(end_time-start_time) * 24/60 t.

    TO_NUMBER(END_TIME-START_TIME) * 24/60

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

    .0145

    SQL > select to_number(end_time-start_time) * 60 * 60 t.

    TO_NUMBER(END_TIME-START_TIME) * 60 * 60

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

    130,5

    SQL > select to_number(end_time-start_time) * 60 * 60/24 t;

    TO_NUMBER(END_TIME-START_TIME) * 60 * 60/24

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

    5.4375

    Hello

    Search Date arithmetic in the manual of the SQL language.

    When you subtract one DATE from another, the result is the number of days between them.  .03625 days is a little more de.033333333... days, which is 1/30 a day, or 48 minutes.

    If you want the difference in hours, multiply by the number of hours per day, which is 24.

    If you want the difference in minutes, multiply by the number of minutes per day, or 24 * 60.

    If you want the difference expressed in days hours: minutes: seconds, then you are better off conversion (at least) one of the DATEs in TIMESTAMP; then, when you subtract them, you will get the difference as an INTERVAL DAY TO SECOND, which appears as

    + 05:06:37.000000 000000000

    This means that 0 days, 5 hours, 6 minutes, 37 seconds.

  • The ABS function and the sum at a time

    <? If: sum (ARCH_AMT)! = '0' ? >

    We used above condition in the model to restrict the data to date, but we were faced with a new problem when ARCH_AMT is to have several lines with the same amount but + ve and ve - that is to say 500, -500, is the sum and do not return data given that the sum would be zero.

    We do ABS (ARCH_AMT) before making the sum that the SUM will be thousand and data will be collected.

    Please suggest how can we have ABS and the sum at a time

    I tried

    <? If: sum (ABS (ARCH_AMT))! = '0' ? > and also choose the conditions and it does not work.

    Thanks in advance.

    Kind regards
    Mahi

    Published by: mahi4luck on March 28, 2012 02:33

    store ABS (ARCH_AMT) in a variable and use this variable in a total cumulative

    example:
    Suppose I have a structure xml like this:



    -500


    500





    Total:

  • sum of column that contains the values in the time format

    Hi all

    I give you a piece of my code below
    SELECT  dif.EMPLOYEE_NUMBER Employee#, dif.FULL_name EmployeeName,
     TO_CHAR(START_DATE,'dd-Mon-rrrr') DOJ ,dif.DEPT_NAME,POSITION , DATE_ENTRAY AttendanceDate,
    
     to_char(DATE_ENTRAY,'DY') day, TO_CHAR(LNE1,'hh24:mi')TimeIn1 ,TO_CHAR(LNE2,'hh24:mi')TimeOut1,
     
     TO_CHAR(LNE3,'hh24:mi')TimeIn2 ,TO_CHAR(LNE4,'hh24:mi')TimeOut2, TO_CHAR(LNE5,'hh24:mi')TimeIn3 ,
    
     TO_CHAR(LNE6,'hh24:mi')TimeOut3, to_char(decode(LNE8,null ,
    
     decode(LNE7,null, decode(LNE6,null, decode(LNE5,null, decode(LNE4,null, decode(LNE3,null,
    
     decode(LNE2,null,LNE2 ,LNE2 ),LNE3 ),LNE4 ),LNE5 ),LNE6 ),LNE7 ),LNE8 ),'hh24:mi')TimeOuts ,
     
     ACT_HOUR Work_Hrs, 
    
    decode(DLY_ABSENT_TYPE,'Late',DED_ABS ,'Late (Deduction)',DED_ABS,'00:00') Late_Hrs,ACT_OVT Over_Time
     FROM jjj_PUNCH_DATA_EMP_LIST trn , 
     jjj_emp_def dif,jjj_PUNCH_CARD_ELEG ele WHERE trn.EMPLOYEE_NUMBER =dif.EMPLOYEE_NUMBER and   
     ele.EMPLOYEE_NUMBER =trn.EMPLOYEE_NUMBER  and   DATE_ENTRAY between '23-Aug-2009' and  '24-Aug-2009' 
    
    I require to find the sum of column  wrk_hrs
    Act_hour or wrk_hrs belongs to table  jjj_PUNCH_DATA_EMP_LIST trn , and the datatype of act_hour is varchar(10 byte)
    the values of column act_hrs, (i require the sum of this column)
    08:00
    07:22
    06:08
    kindly help
    thanking in advance

    concerning
    Oracle user

    Hello

    Thanks for posting the CREATE TABLE and INSERT. That really helps.

    Do you want 19:33 ' as the output? Which makes it look like 19 hours and 33 minutes. Most people would represent 19.33 hours (i.e. 19 more than 1/3 hours) as 19:20 '. Should not the sum of
    ' x: 00 ' and
    'y: 20' be
    "z: 20?

    If you really want 19:33 ', see the solution of Hoek.

    If you really want 19:20 ', then you were on the right track.
    I think that you were trying to do:

    WITH  got_total_hours     AS
    (
         SELECT SUM (   TO_NUMBER (SUBSTR (act_hour, 1, 2))
                    + ( TO_NUMBER (SUBSTR (act_hour, 4, 2))
                      / 60
                      )
                    ) AS total_hours
         from      p
    )
    SELECT        TO_CHAR (FLOOR (total_hours))
           || ':'
           || TO_CHAR ( MOD (total_hours, 1) * 60
                   , 'fm00'
                   )     AS hh_mm
    FROM     got_total_hours
    ;
    

    Looks like you were trying calculate total_hours in a subquery, then use the total_hour alias in a query Super, which is quite accurate. You're just confused on how to write a subquery.
    There are two basic ways to write subqueries:

    (1) WITH clause:

    WITH  sub_query  AS
    (
         SELECT  ...
    )
    SELECT  ...
    FROM      sub_query
    ;
    

    (2) online review

    SELECT     ...
    FROM     (     -- Begin sub_query
         SELECT     ...
         )     -- End sub-query
    ;
    

    Looks like you tried a bit of each method.

    In most cases (this included problem) either one will work.
    Other problems are much easier by using a WITH clause and WITH clauses are usually easier to read and understand, I recommend that you always use a WITH clause rather than views online.

    You can also change the Hoek solution to get the result 19:20 ' without a subquery (or without using any expression complicated, more than once, which is the only reason why I have proposed a subquery). Since date arithmetic Oracle comes from the days, not hours, when the solution of Hoek has calculated the number of hours, you'll have to divide by 24 to get the number of days. If you are using TO_CHAR to fit the time, however, the results can be confusing if the total is 24 hours or more. You might be better off using NUMTODSINTERVAL.

  • If the time in my computer shows 19:55 Feb 12 why health report shows two points (events) on February 13 in the last start of chart of the day

    I use 14.04.1 ubuntu lts. my version of firefox is 35.0.1 and what update it says that it is the last available.
    I fear that the health report shows activity on 13 February, when my computer is on 12 February at 20:00.
    is it posible that someone has control over my internet conection and the person is 5 hours of my time zone?
    or y at - it an explanation for this behavior of the report health firefox?
    Thanks in advance for your help
    I am downloading and the image of my screen where it shows my time in the top right of the screen and report on health with two events on Feb. 13.

    All computers use UTC (Coordinated Universal Time) internally, Greenwich time average aka, alias ZULU, as is called the US Navy. http://en.Wikipedia.org/wiki/UTC
    Then the operating system subtracts the UTC offset as indicated in the user settings to the "local time". This shift from 5 hours to the hour UTC indicates the time Zone Eastern North Americam.

  • My verse ATT modem (non apple devices to use this modem} is connected to the ATT line, Time Capsule (iPhones, Macs Time Capsule use) via ethernet Uverse.) Non apple devices can collect data from iPhones or Mac using the time Capsule?

    My verse ATT modem ({use of devices not apple wifi of this modem} is connected to the ATT line, Time Capsule (iPhones, Macs use the wifi of the time Capsule) and connect to the Uverse modem via ethernet.)

    Both devices are set to the highest security and each uses separate passwords.

    Non apple devices can collect data from iPhones or Mac using the time Capsule?

    With a bit of work by someone who knows how to do such things, not Apple computers could read some files on the Mac if file sharing is configured on the network... devices non-Apple and... He knew the device passwords or administrator for Macs.

    Mac could also play the files on other Macs if file sharing has been implemented and the device password or admin was known.

    If you ask if a PC can read the files on the Time Capsule, the answer is Yes, without doubt, assuming that the PC knew the password of device for the time Capsule.

  • Changed the time on pc and suddenly will not work Skype?

    Hi I just got this phone today and have already run into large sum of problems. I misclicked by set up of windows 8 and taken the wrong time zone, forget I did what I leave the laptop itself implemented, I didn't know it until I had already installed and was on Skype. I thought nothing of it, changed the clock to the correct time and now all of a sudden every time I send a message on Skype it just sends me upward into the conversation. I'm not all messages and I don't see any of the envoys of the mine. I uninstalled Skype 3 times and still can not solve it? I got Skype running on my desktop and thought maybe that was it but atlast, no. I am only signed on this laptop and can't use Skype. I even downloaded an older version it and still no luck.

    I run a malware scan as I tpye this, but I don't think it'll be very successful. Does anyone have an idea how to solve this problem?

    In fact, I just thought to it. So I got to do some time apparently traveling thanks to me by clicking on the wrong time, I was 3 hrs behind, always in August 3. When I changed the time zone, he just changed the time and NOT the date. So, I was in the good times but the wrong date. Skype has been send all my messages and everything everyone elses to August 3 instead of 4 August 03:00 03:00. I feel like a complete fool for overlooking it, but I just thought that it would change the date with time.

  • Calculation of the time of numbers

    Hello

    I am wondering how to calculate the amount of time in a cell for a while and have the result show the amount of time in hours and minutes

    what I have is a cell with once inside, for example 06:30, and I want to be able to have the next cell in the row to calculate the time between the first cell and a static time of 07:00 culminating at 00:30 (30 minutes).

    I played with formulas as IF (C2

    How can I go about it?

    Thank you

    Hi lgp,.

    Subtract the twice to get a period.

    Formula in B2 (fill down)

    = B$ 1−A2

    Know in numbers, when you enter a time, he always has a Date (even if the skins of cell data Format Date, it's still there).

    So in A9, entering at 06:30 on Dec. 12, B9 show the number of minutes 1 day in less than 30 minutes (because B1 was seized Dec. 11). Therefore:

    Kind regards

    Ian.

    .

  • How can I measure the time between the two edges of successive increase, using digital input...

    Hello

    I'm trying to measure the time in seconds between each two successive rising edges on a digital input.

    So far I managed to detect the rising edge, increment a counter at each rising edge and take the time during which the increase is edge

    all I need now is subtract edge currently rising from the previous era of edge rising to calculate (T), which can be 1/frequency and display in real time for the user.

    but I do not know how to do this

    Can someone help me please!

    Note: while I am in a position varies between 200 ms - 2 seconds


  • Take the time between two values

    Hi people,

    I have a problem and I know idea how to solve... I need help.

    The problem is I want to take the time between two values max as you can see in the chart.

    For example, in the image that I have add

    4.5 - 1 840 = 2.66

    And enter this value in the 'time between mostra '.

    It's that I want...

    But what I think is very complicated, because I don't know how to take the time correctly and does remove...

    Thank you very much

    Any solution?

    Hi jocuma,

    I tried something and hope that helps u.

    Just create two arrays of temperature and voltage. First of all, I'll get the value of the voltage when it is more of a certain value and that same index to get the value of time and store in the shift register.

    When I get the second higher than the limit value, I'll get time and subtract the previous value.

  • triggering event for the time of day

    I'm trying to put in place a system that requires taking several samples per day at the fire time (at irregular intervals) and then repeat it every day for a week or two. So far, I have tried to use a TimeStamp control array, but I'm not getting much. Does anyone has any ideas on how to do it, or can point me to an example that I missed in my research.

    Thank you

    So what I would do, is create a loop of events with a single event - a timeout. Conduct of this event would be a picture of the time when an action should be performed. The loop starts, remove the first item and subtract the current time of the time goal. This will give you the time in seconds before the event. Multiply by 1000 to get the number of milliseconds before the time runs out. Feeding this value for the time-out. Then each timeout event fires of time, of the index to the next item and calculate a new delay.

    Mike...

Maybe you are looking for

  • Move the Home icon

    I don't like where the HOME icon now (right of the screen) and you want to move elsewhere. I am able to do?

  • Satellite P305-S8820 - upgrade to Windows 7 Home Premium

    Hi all If I buy Microsoft Windows 7 Home Premium Upgrade Family Pack (3 - User) (DVD-ROM) for my toshiba P305-S8820. 1. I will be able to perform a clean install by reformatting the drive?2. is there a Toshiba utility, which will find all drivers for

  • MXI-4, Manager of configuration problems and data base, clean install MAX

    Hello I have a problem with the MXI-4 kit / PCI-8331 -C' is a clean install of MAX, using the default installation option. -Win XP 32. The PCI-8331 is the only PCI site in PC With the GUI of MAX does not, plug-and-play detects the jury. If I reboot,

  • Support need help but they ignore me

    I waited five days for microsoft to respond to my hotmail password reset. Nobody seems he cares about their customers, knows is it possible to get their help?

  • Adding another DV6 HARD disk?

    Hello I was wondering if I can add another HARD drive to my Pavilion dv6-6070ee. I want to buy an SSD and install side by side with my 500 GB HARD drive is this possible?