0
I am mounting a graph containing the amount of CHATS that were answered in a given time, example:
1-30s -> 20 chats answered
31-60s -> 66 chats answered
60-120s -> 4 chats answered
I’m confused on how to return this using a query
The basic structure of my table is:
ID | Title | Chat duration
1 | Test | 20
2 | Teste2 | 66
To get the average duration, I use the code below:
$filter['filtergt']['user_id'] = 0;
$filterCombined = array_merge_recursive($filter,array('filtergt' => array('chat_duration' => 0),'filter' => array('status' => erLhcoreClassModelChat::STATUS_CLOSED_CHAT)));
return erLhcoreClassChat::getCount($filterCombined, 'lh_chat', 'AVG(chat_duration)');
I believe with Queries it solves, but I’m not sure
Obs: only the query solves, or the idea, and I implement in the system
Take all the chats and do the one-to-one check of the duration I believe is not feasible, thinking of large amounts of existing chats
Hello, it works correctly, however I added 2 more conditions (60-90 and 90-120) and for some reason, the fifth (that would be the "Else") is not activated, nor if I put other conditions, only returns the first 4, but works correctly with this exception
– Everton Neri
Make an example by playing what you did and post the link.
– Woss
here is http://sqlfiddle.com/#! 9/56ac7/1/0
– Everton Neri
I didn’t understand what was wrong there. The result seemed right.
– Woss
Friend, I was going to answer now. My fault, I didn’t notice the order in which the records returned, and I thought one was missing, it’s really correct, sorry!
– Everton Neri