i want display result of missing time gaps between each half-hour and. how can achieve this? query:
set @userid=8; set @start = '2015-07-20 08:00:00'; set @end = '2015-07-20 17:00:00'; select from_unixtime((unix_timestamp(time_of_call) div (30*60)) *30*60) elapsed, count( call_id ) value calls calling_agent = @userid , time_of_call > @start , time_of_call < @end group unix_timestamp(time_of_call) div (30*60) order time_of_call desc
you can use group unix_timestamp(sub1.sdate) div (30*60) group 30 minute slot.
to show slot start time can use from_unixtime((unix_timestamp(sub1.sdate) div (30*60)) *30*60)
edit due edited question:
here matching code:
select * calls right join ( select from_unixtime(unix_timestamp(@start)+(v1.v+v2.v+v3.v+v4.v+v5.v)*30*60) vv (select 0 v union select 1) v1 cross join (select 0 v union select 2) v2 cross join (select 0 v union select 4) v3 cross join (select 0 v union select 8) v4 cross join (select 0 v union select 16) v5 ) tx on (from_unixtime(unix_timestamp(time_of_call) div (30*60)*30*60)=vv) calls.calling_agent=@userid , calls.time_of_call null , from_unixtime(unix_timestamp(@start)+(v1.v+v2.v+v3.v+v4.v+v5.v)*30*60) < @end;
Comments
Post a Comment