Hi. I'm a newbie who's just started using SQL and I'm trying to build a report which looks at the most-recent activity completion date (Task.CompletionDate), and then pulls back the most-recent creator of that particular activity (ActivityCreator.Fullname).
Here is the SQL code:
Code:
SELECT
ActivityCreator.FullName as 'Activity_Creator'
,crm.Task.CompletionDate
,crm.Task.CreatedByID
CASE
WHEN ActivityCreator.FullName = 'Person 1' THEN 'Team 1'
WHEN ActivityCreator.FullName = 'Person 2' THEN 'Team 2'
WHEN ActivityCreator.FullName = 'Person 3' THEN 'Team 3'
END AS 'Activity_Owner_Team'
FROM
INNER JOIN crm.Users ActivityCreator
on ActivityCreator.UserID = crm.Task.CreatedByID
WHERE ActivityCreator.FullName IN ('Person 1', 'Person 2', 'Person 3')
Any help would be gratefully appreciated.
Thanks in advance,