Good morning,
These are trying to make a select to select only the attendants who have the number of calls below the average.
It seems simple, but I'm not getting it, I've tried it in several ways ...
I would not have to count the number of calls in the WHERE to put something like "Count (*) & media;"
Thank you.
$ average = '40';
SELECT a.adminID
from os
JOIN cadastroCliente cc ON cc.cadastroClienteID = os.idcliente
JOIN administrador a ON a.adminID = os.idusuario
WHERE os.idusuario = a.adminID
AND os.status = '1'
AND os.respondido = '0'
ORDER BY RAND()
LIMIT 1