Solved

my average waiting time question?

Posted on 2006-11-13
3
280 Views
Last Modified: 2013-12-24
I have a support system written in ColdFusion and now would like to generate a report using some of data I have in the backend database.

I need to output the average waiting time this month for my tickets

In my database each ticket has a time and date,  i need to know how i would pull these and work out this..

so example data in my database would be

ticketID          datetime
1                   Nov 13 2006 5:05PM
1                   Nov 13 2006 5:05PM
1                   Nov 13 2006 5:05PM
1                   Nov 13 2006 5:05PM
2                   Nov 13 2006 5:05PM
2                   Nov 13 2006 5:05PM
3                   Nov 13 2006 5:05PM
3                   Nov 13 2006 5:05PM

1) i first need to  get  all tickets out of the database, take the first datetime for each ticket.
2) then i need to get the second datetime for each ticket (if it has one) as this is the first time the ticket was responded to, all datetimes after that for that ticket does not matter.

we now have all the start datetime of the each ticket and all the first post (the response) of all tickets

3) i then need to work out the average waiting time per month based on the set of data i have for all the tickets

can you see now why i am so confused? after all that i would like to maybe use the new cfchart to present my data?

is any of this possible and could anyone give me a hand understand this?


0
Comment
Question by:pigmentarts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 500 total points
ID: 17935010
Here is an idea...

select t.ticketID
      , MIN(t.[datetime]) as firstdate
      ,(
            select TOP 1 [datetime]
            FROM ticket
            WHERE ticketID = t.ticketID
            AND [datetime] <> MIN(t.[datetime])
            ORDER BY [datetime]
      ) AS seconddate
      ,
CAST(
      (
            (
                  select TOP 1 [datetime]
                  FROM ticket
                  WHERE ticketID = t.ticketID
                  AND [datetime] <> MIN(t.[datetime])
                  ORDER BY [datetime]
            )
            - MIN(t.[datetime])
      )
      AS float
) AS waittime
INTO #temp
from ticket t
GROUP BY t.ticketID

select avg(waittime) FROM #temp





0
 
LVL 12

Author Comment

by:pigmentarts
ID: 17936799
cool, i used you example above, just one last question, possible to exstend this a bit and only output the avg for this month i.e. only show the waiting time for the current month?

<cfquery name="getDomain" datasource="#dbSource#" username="#dbUsername#" password="#dbPassword#">



select t.ticketID
     , MIN(t.[datetime]) as firstdate
     ,(
          select TOP 1 [datetime]
          FROM issues
          WHERE ticketID = t.ticketID
          AND [datetime] <> MIN(t.[datetime])
          ORDER BY [datetime]
     ) AS seconddate
     ,
CAST(
     (
          (
               select TOP 1 [datetime]
               FROM issues
               WHERE ticketID = t.ticketID
               AND [datetime] <> MIN(t.[datetime])
               ORDER BY [datetime]
          )
          - MIN(t.[datetime])
     )
     AS float
) AS waittime
INTO temp
from issues t
GROUP BY t.ticketID


</cfquery>


<cfquery name="getavg" datasource="#dbSource#" username="#dbUsername#" password="#dbPassword#">
select avg(waittime) AS wtime  FROM temp WHERE waittime IS NOT NULL
</cfquery>

<cfoutput query="getavg">
#wtime#
</cfoutput>
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 17936983
sorry done that, thanks
0

Featured Post

Don't Miss ATEN at InfoComm 2017!

Visit booth #2167 to see the  new ATEN VM3200 32 x 32 Modular Matrix Switch. Other highlights include the VE8950 4K HDMI Over IP Extender, VS1912 12-Port DP Video Wall Media Player  and VK2100 ATEN Control System. Register now with Free Pass Code ATEN288!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IIS 8.5 2 54
IIS url rewrite rule for web application 3 69
SSL sertificate 5 84
DNS @ Naked Domain Record 5 133
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question