mysql - AVG or SUM in SQL where the values are being calculated on the fly -
I have an existing SQL query that gets call stats from a Zultys MX250 phone system: - The output is as follows: - I am trying to produce a fourth column which is average for each The call time shows the user, but how to figure out how. Mathematically it is only struggling to see the "Duration" / "#Calls" "But after seeing some similar questions on StackOverflow, examples of questions are also simple to help me related Right now, I do not even believe it is possible to split the column with the number of columns. UPDATE : I was very close to my trial but all were confused and amp; More work here is the latest SQL (thanks to @ McAdam331 & my partner work gym): - The output is as follows: -
select concat (left (u.firstname, 1), name as left (u.lastname, 1)), sec_to_time (sum (time_to_sec (s.disconnecttimestamp) - time_to_sec (s.connecttimestamp)) ) As the period, join the session '#Calls' as COUNT (*) as s.ExtensionID1 = u.ExtensionId or s.ExtensionID2 = u.ExtensionId on mxuser u where s.ServiceExtension1 zero and s.connecttimestamp & Gt; = CURRENT_DATE and binary u.userprofilename = Binary 'DBAM' group by U.Fastamen, U. Ostine '# Call' by DESC, DESC Duration; Name Period # hour went 01:19:10 30 AS 00:44:59 28 EW 00:51:13 22 SH 00:21:20 13 MG 00:12:04 8 TS 00:42:02 5 DS 00:00:12 1
select concat (left (u.firstname, 1), left ( U.lastname, 1) duration, '#Calls' as COUNT (*), sec_to_time (sum (as time_to_sec (s.disconnecttimestamp) - time_to_sec (s - name, sec_to_time (time_to_sec (s.connecttimestamp)) Connect as much as the session (time_to_sec (s.disconnecttimestamp). ConnectTamstamp)) / / (*)) Join more sessions than sessions, Extensid 1 = U Extension ID or S. ExtensionID2 = U. Extension IDs where S. Service Extension 1 Zero and s.connecttimestamp> = CURRENT_DATE and Binary U.userprofilename = Binary 'DBAM' group by u.firstname, u.lastname ORDER by average DESC; Name Period # Call Average DS 00:14:25 4 00:03:36 MG 00:17:23 11 00: 01:34 ts 00:33:38 22 00:01:31 EW 01:04:31 43 00:01:30 AS 00:49:23 33 00:01:29 TH 00:43:57 35 00:01: 15 SH 00:13:51 12 00:01:09
OK, you can get it Number of seconds of total, as you do before changing it on time, why not take the total number of seconds, divide by the number of calls, and then by changing back to that time Not?
SELECT sec_to_time (SUM (time_to_sec (s.disconnecttimestamp) - time_to_sec (s) .connecttimestamp)) / COUNT (*)) As the average duration
Comments
Post a Comment