Cohort query to determine sum of time elapsed between 2 date fields


I want to create an indicator report to display average doctor turn around time for the visits created in the openmrs. The formula to determine doctor TAT is sum(timediff between date_stopped & date_created) for the visit divided by total number of visits in the openmrs. Can anyone guide me to achieve this indicator?

Don’t you want to group this by doctor/provider?