GETTING THE AVERAGE OF TIME

Hi,I have the following code which returns day of week name, position and date and time of surgeries.
SELECT
DATENAME(WEEKDAY,OPE_START_TIME) AS DOW,
[OPE_ORDER_IN_SESS_ASC] AS POSITION,
OPE_START_TIME AS [TIME]
FROM table1The data looks like thisHow can i group this data so I get the average start time by day of week and position?

try this
\declare @table table(c1 varchar(20),c2 int,c3 datetime2(0))
insert into @table
values('monday',1,'2015-04-29 02:09:42')
,('monday',1,'2015-04-29 02:05:42'),
('tuesday',1,'2015-04-29 02:59:42')
,('tuesday',2,'2015-04-29 02:55:42')
;with cte as (select avg(datepart(second,c3)+((datepart(minute,c3)+(datepart(hour,c3)*60))*60)) as c3
,c2,c1 from @table
group by c1,c2)
select right('0'+cast(c3/3600 as varchar),2)+':'+right('0'+cast((c3%3600)/60 as varchar),2)
+':'+right('0'+cast((c3%3600)%60 as varchar),2) as [AvgTime],c2,c1 from cte
Hope it Helps!!

Similar Messages

  • I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells, find the 10 lowest numbers, then get the average and after that multiply it by .96

    I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column,  find the 10 lowest numbers, then get the average and after that multiply it by .96  I used to use Excel and the formula worked fine in that. Here is my Formula
    =(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
    This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
    The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96  So instead of using 1 cell, I'm using 12 cells to get my answer.
    This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
    Hoping I explain myself well enough and that someone can help me.
    Thanks

    You can still do it in one cell but it will be more unruly than the Excel array formula.
    =average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
    where you would, of course, replace the "..." with the remaining six SMALL functions.

  • I am having troubles, when I open LR I get a message that there is an error and it will try to fix the error next time it opens, but I get the error next time it opens, and this is going on and on where I can not use LR, any suggestions?

    I am having troubles, when I open LR I get a message that there is an error and it will try to fix the error next time it opens. LR closes on it's own, I reopen it and get that same message next time it opens, and this is going on and on where I can not use LR, any suggestions? If I click on a different set of photos in the libary before I get that message I might or might not get the message next time it oipens, but I still can not get to those photos, and it is not just one or two but most of my photos. HELP!!!!
    Thanks
    Carol

    The first thing I would suggest is for you to go to the folder containing your catalog, using your system browser. There will be a folder that has the extension .lrdata. Delete that folder, and then try to start Lightroom. If that doesn't work, replace your catalog with your most recent backup.

  • How to get the total execution time from a tkprof file

    Hi,
    I have a tkprof file. How can I get the total execution time. Going through the file i guess the sum of "Total Waited" would give the total time in the section "Elapsed times include waiting on following events:"
    . The sample of tkprof is given below.
    SQL ID: gg52tq1ajzy7t Plan Hash: 3406052038
    SELECT POSTED_FLAG
    FROM
    AP_INVOICE_PAYMENTS WHERE CHECK_ID = :B1 UNION ALL SELECT POSTED_FLAG FROM
      AP_PAYMENT_HISTORY APH, AP_SYSTEM_PARAMETERS ASP WHERE CHECK_ID = :B1 AND
      NVL(APH.ORG_ID, -99) = NVL(ASP.ORG_ID, -99) AND
      (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'ALWAYS' OR
      (NVL(ASP.WHEN_TO_ACCOUNT_PMT, 'ALWAYS') = 'CLEARING ONLY' AND
      APH.TRANSACTION_TYPE IN ('PAYMENT CLEARING', 'PAYMENT UNCLEARING')))
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    442      0.08       0.13          0          0          0           0
    Fetch      963      0.22       4.72        350      16955          0         521
    total     1406      0.31       4.85        350      16955          0         521
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 173     (recursive depth: 1)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             1          1          1  UNION-ALL  (cr=38 pr=3 pw=0 time=139 us)
             1          1          1   TABLE ACCESS BY INDEX ROWID AP_INVOICE_PAYMENTS_ALL (cr=5 pr=0 pw=0 time=124 us cost=6 size=12 card=1)
             1          1          1    INDEX RANGE SCAN AP_INVOICE_PAYMENTS_N2 (cr=4 pr=0 pw=0 time=92 us cost=3 size=0 card=70)(object id 27741)
             0          0          0   NESTED LOOPS  (cr=33 pr=3 pw=0 time=20897 us)
             0          0          0    NESTED LOOPS  (cr=33 pr=3 pw=0 time=20891 us cost=12 size=41 card=1)
             1          1          1     TABLE ACCESS FULL AP_SYSTEM_PARAMETERS_ALL (cr=30 pr=0 pw=0 time=313 us cost=9 size=11 card=1)
             0          0          0     INDEX RANGE SCAN AP_PAYMENT_HISTORY_N1 (cr=3 pr=3 pw=0 time=20568 us cost=2 size=0 card=1)(object id 27834)
             0          0          0    TABLE ACCESS BY INDEX ROWID AP_PAYMENT_HISTORY_ALL (cr=0 pr=0 pw=0 time=0 us cost=3 size=30 card=1)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                       350        0.15          4.33
      Disk file operations I/O                        3        0.00          0.00
      latch: shared pool                              1        0.17          0.17
    ********************************************************************************

    user13019948 wrote:
    Hi,
    I have a tkprof file. How can I get the total execution time.
    call count cpu elapsed disk query current rows
    total 1406 0.31 4.85 350 16955 0 521TOTAL ELAPSED TIME is 4.85 seconds from line above

  • HT3275 I get the following message - "Time Machine could not complete the backup."  "Unable to complete backup."  "An error occurred while creating the backup folder.""

    I get the following message - "Time Machine could not complete the backup."  "Unable to complete backup. An error occurred while creating the backup folder."" 
    This MAC is partioned with Windows 7 with only  50 gig devoted to Windows so my son can play Flight Simulator X on the machine. 
    I have a WD Passport External Hard Drive for the Back Up
    I have spoken with WD Tech Support and they have been fantastic but I still keep getting this message.  Any thought?
    Maxx

    Reboot the TC.. it sometimes gets lost on the network.. are you still actually using 10.6.8 as the problem is more prevalent on Lion and ML it seems is no better.
    You might find reset of the TC is needed. change the names to short, no spaces pure alphanumeric.
    Reset the TM to the new name.. use the A4 in Pondini's great KB.
    http://pondini.org/TM/Troubleshooting.html

  • How to get the current GMT time in java

    Hi,
    How to get the current GMT time in java
    Thanks

    System.getCurrentTimeMillis() or new Date().
    [url http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates
    [url http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format

  • How to get the date n time for log in ODI

    Hi,
    I wanna ask, what is the syntax for getting the date n time when i specify the location of log for Interface. Thanks.

    I quite do not get what you are trying to achieve here.
    - In a mapping, use the DBMS engine sysdate command.
    - In a variable, you can refresh the variable value using a "select sysdate from dual" type of query.
    - You can also use the appropriate odiref substitution method to get a date. For example:
    Current year is: :<%=odiRef.getSysDate("y")%>
    Hope this helps.
    -FX

  • How do you get the average of an array bigdecimels

    how do you get the average of an array bigdecimels... I am looping through the array in a for loop
    for (int i = 0; i < prItems.length; i++) {                                                                                                                                                                                                                                                                                                                  

    int sum = 0;
    for (int i = 0; i < prItems.length; i++) {
    sum = sum + prItems;
    int avg = sum/prItems.length;

  • How to get the latest update time of a info provider in ABAP

    hi experts,
    i am doing a ABAP program and need to get the latest update time of a info provider , does anyone know where it stores in BW or any other way to get it?
    many thanks
    WHY

    Table : RSREQDONE
    you can give INFOPAK_ID as parameter and search for latest/last Request ID and dispaly time and Date.
    Cheers
    Praveen

  • The Average Wait Time of SQL instance "CONFIGMGRSEC" on computer " SEC_SITE_SERVER " is too high

    I have a SCCM 2012 SP1 CU4 environment with SCOM monitoring installed.
    I also do have 4 secondary sites installed below my primary. The secondaries are using SQL 2012 Express version default deployed using the secondary site installation.
    My SCOM monitoring is generating tickets with the following message:
    The Average Wait Time of SQL instance "CONFIGMGRSEC" on computer "<SEC_SITE_SERVER>" is too high
    How can i solve this ? Or do I need to ignore this ?

    Never ignore messages, but tune them.
    In this specific case you might want to take a look at this:
    http://social.technet.microsoft.com/Forums/en-US/ffeefe0d-0ef7-49a3-862e-9be27989dc5d/scom2012-alert-sql-2008-db-average-wait-time-recompilationis-too-high?forum=operationsmanagergeneral
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • How can I get the date and time and display it on the report main page?

    Gurus,
    How can I get the date and time and display it on the report main page?
    Thanks!

    Hello,
    You can create a Formula Colum returning a date :
    function CF_1Formula return Date is
    begin
    RETURN(SYSDATE);
    end;
    Put a Field in the Layout having this formula column as source .
    Regards

  • Get the date and time from iframe.

    Hi,
    Am using jdeveloper 11.1.1.6.0., I have used the following iframe source which gets the date and time.
    <af:form>
    <iframe src="http://free.timeanddate.com/clock/i3xb4nm0/n1722/tt0/tw0/ts1" frameborder="0" width="244" height="19">
          </iframe>
    </af:form>
    I need to get the date and time separately to perform some validation. How can i  get it.
    regards,
    Prasad K T,
    9840021070

    Prasad,
    I don't understand your use case. The url you use is a json web service which returns it's result as either xml or json payload. Why do you pretty print this as a web page and try to get to the result this way?
    Why don't you get the result directly using the json result or (AFAIK) the java script api which the service also provides.  Check the documentation of the service.
    From your description I understand that the user enters a time. You need to know if the time is before or after 2:30pm and have to set a 'shift' to A or B.
    Where do I need a timeservice in this validation?
    From what I see your approach won't work. As I still don't understand the use case I don't know how to help.
    Timo

  • Ical problem already 3 weeks after the update, get the message every time username or password is incorrect as I do with this password and username in mobileme bowl. now get the message The server responded with \ 'HTTP/1.1 409 Conflict \'. can someone he

    Ical problem already 3 weeks after the update, get the message every time username or password is incorrect as I do with this password and username in mobileme bowl. now get the message
    The server responded with \ 'HTTP/1.1 409 Conflict \'.
    can someone help me

    Ical problem already 3 weeks after the update, get the message every time username or password is incorrect as I do with this password and username in mobileme bowl. now get the message
    The server responded with \ 'HTTP/1.1 409 Conflict \'.
    can someone help me

  • XMII 12.x  Can you get the Server's Time Zone from a webservice call?

    Is there a MII / NW webservice call to get the server's time zone?

    After thinking about it a little my best approach was just a simple JSP page, because I really was more intersted in the servers GMT offset.
    <%@page import="java.util.*" %>          
    <%
    Calendar myCalendar = new GregorianCalendar();  
    int gmtOffset = (myCalendar.get(Calendar.ZONE_OFFSET) + myCalendar.get(Calendar.DST_OFFSET))/(1000 * 3600); 
    %>
    <%=gmtOffset %>

  • How cost;ly it is to get the current system time

    I am using this call "System.currentTimeMillis()" to get the current system time. I need to now how costly it is to get the current system time.

    Why don't you time it -:) Run it 10000 times and print the first and last result. The difference is the time it took.

Maybe you are looking for