select pel.identifier as 'Patient Id', pel.date_created as 'Registration Date', u.username as 'Updated By', count(pel.identifier) as 'Edit Count' from person_edit_log pel inner join users u on pel.changed_by = u.user_id where cast(pel.date_changed as DATE) between '#startDate#' AND '#endDate#' group by pel.identifier, u.username;