Search Results
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 |
14
votes
Accepted
Aggregate SOQL - How Many Fields Can Be Grouped?
The maximum is 32 groupings. If you exceed this, you receive the following error:
System.QueryException: Group By must contain 32 fields or less
This used to be in the documentation, but I can't seem …
7
votes
Accepted
SOQL SUM() function not calculating the correct value
Any time you use an aggregate function, it is always in the organization's currency. … You can’t convert the result of an aggregate function into the user’s currency by calling the convertCurrency() function. …
5
votes
Accepted
get MIN date with Id from aggregate result query
In this specific case, it'd be a lot easier to order by date ascending and limit by 1:
MyObject__c minDOBRecord = [SELECT Id FROM MyObject__c WHERE Id = :setIds ORDER BY DOB__c ASC LIMIT 1];
In rea …
5
votes
What is the coalesce() eqivalent?
No. There's no way to get the results you're looking for. SOQL is a very limited query language that isn't as robust as full SQL, although it handles relationships easier than SQL.
4
votes
Accepted
convert aggregate result to list
Just use the AggregateResult directly. If you decide to serialize it, your data would look like this:
[
{
"attributes": {
"type": "AggregateResult"
},
"Name": "Account 0 …
4
votes
Accepted
How can I prevent a ContentDocument being deleted when it is linked to a record meeting cert...
It should be as simple as:
AggregateResult[] results = [
SELECT COUNT(Id) recordCount, ContentDocumentId documentId
FROM ContentDocumentLink
WHERE ContentDocumentId IN :contentDocumentIds
AN …
3
votes
Accepted
AggregateResult Use Case Best Practice
Use AggregateResult when possible. It always performs at least as well as manual loops. The more rows you need to process, the more you'll save in CPU time.
3
votes
How can you aggregate a checkbox field with SOQL?
You'll need to calculate the average manually. You'll want to group the data like this:
SELECT Count(ID), OwnerId, MyCheckbox__c FROM Object__c GROUP BY OwnerID, MyCheckbox__c
You could map the ave …
2
votes
Accepted
Why is my aggregate query returning no rows when called during test?
You're running into the Isolation of Test Data from Organization Data in Unit Tests. In other words, by default, unit tests can't see live data. This makes your unit tests more reliable, because they' …
2
votes
Accepted
Database.Stateful in Batch gives errors
global List<Sales_Data_Aggregated__c> listSalesDataAggregated_Upsert = new List<Sales_Data_Aggregated__c>();
global List<Sales_Data_Aggregated__c> listSalesDataAggregated_Delete = new List<Sales_Data_ …
1
vote
Updating parent record via Batch Apex
There's no direct way to do this without a bit of extra setup, but it is possible. First, you need to create a new Account Lookup field on Campaign Member. Next, you would want to write a trigger or P …
1
vote
Accepted
Collect text fields in Aggregate Result Query
To get all of the values together by type, you will want to create a map. Here's how you might do that:
Map<String, Set<String>> subTypeValues = new Map<String, Set<String>>();
for(OpportunityLineIte …
1
vote
Accepted
Compile error - Return value must be of type : List
Your method declares that it returns List<Funding_Cycles_TA__c>, but you're actually returning a List<Wk_PerformanceQueryResults>. You'll want to change your return type to match.
1
vote
Accepted
Max aggrigate query has huge cost against # query rows returned limit
Based on comments:
Filtering, ordering by (even with LIMIT), or grouping by a formula field always results in a full table scan. This will result in 50,000+ row errors or non-selective filter errors …
1
vote
Accepted
Null Pointer exception on a Map get()
If zero rows would be returned, there's no entry in the map for the record, so you need to check for that first:
private static void updateRiskScoreTotalOnSiteSurvey(List<Site_Survey__c> newSurveys) { …