SET @fromparam = '2018-12-04';
SET @customer = 773;
set @taskparam = 1;
set @taskfilter=false;
set @taskdefault=false;
SET @toparam = '2018-12-07';

SELECT SUM(EVENTLOGS.eventlogs) AS eventlog_count , EVENTLOGS.event_date, EVENTLOGS.person_id , EVENTLOGS.first_name, EVENTLOGS.last_name  FROM (
SELECT 
    COUNT(E.event_id) AS eventlogs, P.person_id, P.first_name, P.last_name, DATE(E.shift_start) AS event_date
FROM
    eventlog E
        INNER JOIN
    person P ON E.person_id = P.person_id
WHERE
E.is_deleted = FALSE AND
    P.customer_id = @customer
        AND E.shift_start >= @fromparam
        AND E.shift_start < @toparam
        AND (NOT @taskfilter
        OR ((NOT @taskdefault
        AND E.task_id = @taskparam)
        OR (@taskdefault AND E.task_id IS NULL)))
GROUP BY E.shift_start, P.person_id, P.first_name, P.last_name, E.task_id) EVENTLOGS GROUP BY event_date, person_id