Thanks in advance!!
Here is what I have so far:
I am selecting the total amount of tasks by person for a specific owner for a given date range. I am now trying to get the exact daily average for number of tasks for each person.
The problem I am having is that it keeps returning a .00 on the end of the average, rather than the exact average. For example, a person may have 2 tasks in a week; I am getting 0.00 for the average rather than 0.28 or 0.29
SELECT
convert(nvarchar, COUNT(p.personID)) AS count,
CONVERT(decimal(4, 2), COUNT(p.personID) / DATEDIFF(DAY, @startDate, @endDate)) AS average,
p.personID,
p.firstname,
p.lastname,
c.companyname
FROM
Tasks t
JOIN
Person p ON p.personID = t.personID
JOIN
Client c ON c.id = p.employer
JOIN
Commission m ON m.ClientID = c.ID
WHERE
t.created BETWEEN @startDate AND @endDate
AND m.owner IN ('John Doe')
GROUP BY
p.personID, p.firstname, p.lastname, c.companyname
ORDER BY
c.companyname, count DESC