MySQL Multiple Counts within Date Groups -
select calldate, from_unixtime(floor(unix_timestamp(calldate)/(60*60))*(60*60)) grouptime , count(*) cntout asterisk.cdr accountcode = '10102-131' , date (calldate) = date (now()) , calltype = 'outgoing' group grouptime;
i have query groups count every hour of date outgoing calls. there way count of incoming in same query?
try this:
select calldate from_unixtime(floor(unix_timestamp(calldate)/(60*60))*(60*60)) grouptime, sum(calltype='incoming') cntin, sum(calltype='outgoing') cntout asterisk.cdr accountcode = '10102-131' , date (calldate) = date (now()) , calltype in ('incoming', 'outgoing' ) group grouptime;
Comments
Post a Comment