• I added the max expression and fix it.

    AND (select max(datediff(ss,last_batch,getdate()) ) FROM sysprocesses where blocked = @blocker) > 5