Skip to content

Instantly share code, notes, and snippets.

@kevin39
Last active September 23, 2016 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevin39/b93b793c6bae0958d773ef5869ede9e3 to your computer and use it in GitHub Desktop.
Save kevin39/b93b793c6bae0958d773ef5869ede9e3 to your computer and use it in GitHub Desktop.
Asterisk - Agent outgoing call summary per hour
SELECT Heure, ROUND(AVG(nbAppels),2) nbAppelsMoyen
FROM
(
SELECT DATE_PART('day',eventtime) Jour, DATE_PART('hour',eventtime) Heure, count(DISTINCT cid_name) nbAppels
FROM cel
WHERE eventtime >= '2016-02-01 00:00:00'
AND eventtime < '2016-03-01 00:00:00'
AND eventtype = 'CHAN_START'
AND context = 'from-extern'
GROUP BY DATE_PART('day',eventtime), DATE_PART('hour',eventtime)
ORDER BY 1,2
) t1
GROUP BY Heure
ORDER BY 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment