Email User Assigned to Task based on Priority

The purpose of this Task workflow rule would be to email the user assigned to the Task when the "alert on days open" = the how many days the Task has still been open from Task Priority setup.

 

Select Tasks.TaskID, ezy_Users.FullName as PersonName, ezy_Users.Email, Tasks.Category, Tasks.Summary, @ICMID as ICMID

From Tasks  INNER JOIN ezy_Users ON ezy_Users.UserID = Tasks.CreatedUserID  

INNER JOIN Priorities ON Priorities.Priority = Tasks.Priority  

INNER JOIN Status ON Status.Status = Tasks.Status  

Where Status.Closed = 0

And Priorities.AlertOnDaysOpen > 0  

And DateDiff(d, Tasks.CreatedDate, getdate()) >= Priorities.AlertOnDaysOpen  

And ezy_Users.disabled = 0

and ezy_users.email is not null

And (Tasks.TaskID not in   (Select TaskID From TaskChanges   Where TaskChanges.TaskChangeMasterID = @ICMID))