0
Dates are different in your hours as this example:
+---------------------+-------------------+-------+
| DATA | callid | tempo |
+---------------------+-------------------+-------+
| 2021-08-01 12:23:50 | 1627831011.78021 | 345 |
| 2021-08-01 17:08:26 | 1627848459.79020 | 12 |
| 2021-08-03 08:58:24 | 1627905500.80140 | 2 |
| 2021-08-04 09:28:01 | 1627907135.80426 | 114 |
I wanted to add and make the media with these first 2 records of 2021-08-01
, that is only with the days that repeat.
I tried to use the AVG()
(to measure the domed values) and SUM()
but does not work from the following error: ERROR 1111 (HY000): Invalid use of group function
SELECT c.DATA,
c.callid,
AVG(SUM(c.tempo)) AS tempo_medio
FROM (SELECT q.calldate AS DATA,
callid,
ROUND(q.info2) AS tempo
FROM queuelog AS q
LEFT JOIN asteriskcdrdb.cdr o
ON o.uniqueid = q.callid
LEFT JOIN cdrjuncao cj
ON o.uniqueid = cj.uniqueid
AND o.calldate = cj.calldate
WHERE timestamp BETWEEN '1627786800' AND '1630551599'
AND ( agent = '9043'
OR agent = '9043' )
AND ( qname = '717'
OR qname = '721'
OR qname = '701' )
AND action IN ( 'COMPLETEAGENT', 'COMPLETECALLER', 'TRANSFER' )
AND o.uniqueid NOT IN ( '' )) c
GROUP BY c.DATA;
Can someone help me? vlwss
Thank you @Woss ! I understood that you do not need to add with the method
AVG()
and had forgotten theDATE()
, with your answer and example I got what I wanted :) OBS:The tablesqueuelog
,asteriskcdrdb.cdr
andcdrjuncao
has nothing to do with my fault problem.– lucas gobira