I am running the code below in a Task trigger. The subquery on Account returns 0 rows, but the direct Task query returns 1 row; there should be 1 row. Can someone explain why this could be happening. Thanks!
List<Task> debugTaskList = [select activityDate from Task
where ownerId <> :excludedId and isClosed = true
and activityDate != null and AccountId = :acctId
order by activityDate desc nulls last limit 1];
List<Account> debugAcctList = [select Id,
(select activityDate
from Tasks
where ownerId <> :excludedId and isClosed = true
and activityDate != null
order by activityDate desc nulls last limit 1)
from Account where id = :acctId];
system.assert(false, 'acctList = ' + debugAcctList[0].Tasks.size()
+ ', taskList = ' + debugTaskList.size());