I wrote this report to display how long it takes a user to finish their first task. currently it will only display contacts that have tasks. I need it to display both contacts with and without tasks any ideas?
SELECT c.MarketSource AS [Market Source],
Coalesce(u.FirstName + ' ', ' ') + Coalesce(u.LastName, ' ') AS [Producer],
Coalesce(c.FirstName + ' ', ' ') + Coalesce(c.MiddleName + ' ', ' ') + Coalesce(c.LastName, ' ') AS [Lead Name],
t.TaskType AS [Task],
Coalesce (t.workflow_resultchosen_label, t.result, ' ') AS [Task Result],
Dateadd(HOUR, @utcoffset, c.createdon) AS [Received On],
Dateadd(HOUR, @utcoffset, ( MIN (t.completed) )) AS [Completed],
(SELECT COUNT(*)
FROM Quotes q WITH (NOLOCK)
WHERE SaleID IS NULL
AND c.ContactID = q.ContactID) AS [Pending Quotes],
(SELECT COUNT(*)
FROM Sales s WITH (NOLOCK)
WHERE s.Client_ID = c.ContactID) AS [Total Sales]
FROM Tasks t WITH (NOLOCK)
LEFT JOIN Users U WITH (NOLOCK)
ON u.UserID = t.UserID
LEFT JOIN Contacts C WITH (NOLOCK)
ON c.ContactID = t.TargetID
WHERE iLeadPartnerID IS NOT NULL
AND ( c.CreatedOn BETWEEN @startDate AND @endDate )
AND MarketSource IS NOT NULL
AND c.WorkgroupId = @workgroupID
AND Len(c.MarketSource) > 0
AND t.TaskType <> '[=] Auto Email'
GROUP BY c.MarketSource,
u.LastName,
u.FirstName,
c.ContactId,
c.LastName,
c.FirstName,
c.MiddleName,
c.CreatedOn,
t.TaskType,
t.Result,
t.Workflow_ResultChosen_Label
ORDER BY c.LastName,
c.MiddleName,
c.FirstName