Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 24889
1 vote
Accepted

Aggregate child records with multiple values

Yes, using aggregate functions to do this is a valid approach (not the only approach). … It is possible to use aggregate functions on related data, which is very helpful for trying to aggregate data using a junction object (i.e. for a many-to-many relationship). …
Derek F's user avatar
  • 64.1k
4 votes

Inconsistency with error "Aggregate query has too many rows for direct assignment"

A perfect example is "Aggregate" queries. You might think that an "Aggregate" query is one that uses Aggregate functions like COUNT() or MIN() along with GROUP BY. … That's completely logical (heck, you even get an AggregateResult[] from a query that uses Aggregate functions), but incorrect (or, at least, incomplete). …
Derek F's user avatar
  • 64.1k
7 votes
Accepted

What is more effecient , using SOQL AVG() or to query all records and calculate their average

My test code is as follows: Decimal average; // Profiling using SOQL aggregate function Decimal startTime = Limits.getCpuTime(); DateTime startDT = DateTime.now(); average = 0; List<AggregateResult> ar … SOQL Aggregate functions are faster to execute, and put 2 orders of magnitude less stress on your CPU governor limit. …
Derek F's user avatar
  • 64.1k
0 votes
Accepted

Merging all the query in 1 query and get the different result in variables and pass that to ...

When you start needing to put data into multiple buckets that aren't refinements of your search criteria (an example of a "refinement" being something like "count of each status used by date"), then S …
Derek F's user avatar
  • 64.1k