Timeline for Why are the results returned using a subquery different than when querying Tasks directly?
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 6, 2013 at 17:35 | comment | added | JimH | OK, thanks. But I need these queries to be structured the way they are (the second one is used as a summary and I need to avoid too many rows error; the first one will be used as a drill down page, which will show all the tasks, upto 100 rows). These debug queries demonstrate the issue I'm seeing, not the final way I will be implementing my code. Bottom line is, I need to get this structure to work. | |
Apr 6, 2013 at 17:18 | comment | added | crmprogdev |
In your 1st query -> debugTaskList = [select activityDate from Task where ownerId <> :excludedId and isClosed = true and activityDate != null (1st direct set of binds) and AccountId = :acctId (direct final or 2nd bind). In your 2nd query -> debugAcctList = [select Id, (select activityDate from Tasks 'where ownerId <> :excludedId and isClosed = true and activityDate != null` (same 1st set of direct binds on inner query) from Account where id =:acctId (now an indirect "outer", 2nd or "double" bind vs being an inner bind). Do you see the difference in structure?
|
|
Apr 6, 2013 at 16:52 | comment | added | JimH | I'm not sure what you mean by double bind. Can you tell me what part of the code you are referring to? Thanks. | |
Apr 6, 2013 at 16:48 | history | edited | crmprogdev | CC BY-SA 3.0 |
improved formatting for code
|
Apr 6, 2013 at 16:45 | comment | added | crmprogdev | One observation, you have a clearly defined double bind on the 1st query, but it's more of an implicit double bind on the 2nd query. Perhaps that's the actual difference between the two that's causing the discrepancy. If you can reconstruct the query to change the binding, that might somehow change your results. The only other thing that comes to mind to try would be to remove the order by clause to see if it makes any difference. I wouldn't expect it to, but I'm out of ideas. | |
Apr 6, 2013 at 16:27 | comment | added | JimH | I appreciate your help. Changing to != and grouping in parentheses had no effect. The excludedId is just a single user Id we do not want to include in the query. Since excludedId is used in the same way in both queries, its specific value is not relevant to the problem I'm seeing. | |
Apr 6, 2013 at 16:05 | history | edited | crmprogdev | CC BY-SA 3.0 |
added 793 characters in body
|
Apr 6, 2013 at 15:44 | comment | added | crmprogdev | My bad, I had the wrong checkbox clicked when I looked at my DevOrg and created the query. It is indeed a valid field! Without knowing what :excludedId is I can't say if it would return all tasks or not. | |
Apr 6, 2013 at 14:46 | comment | added | JimH | ActivityDate is a valid field on Task. Shouldn't the subquery return all the tasks and the queried Task fields for the account? | |
Apr 6, 2013 at 14:27 | history | answered | crmprogdev | CC BY-SA 3.0 |