The tag has no usage guidance.

learn more… | top users | synonyms

8
votes
1answer
118 views

Aggregate SOQL - How Many Fields Can Be Grouped?

As stated in the title, is there any maximum on the number of fields that can be passed into a GROUP BY clause? I can't find any documentation on it. For example, if I had the following query: SELECT ...
0
votes
1answer
19 views

Aggregate Query Returns Results in Dev Console but not Apex

I have an Apex Class that retrieves an aggregate result of Contacts per Accounts in order to validate a maximum of 2 Contacts of a certain type. I have tried several things. First I used a set and ...
5
votes
2answers
64 views

SOQL Query of lookup relationship

I have an SObject called Team_Member__c It has a lookup field Manager__c pointing to Team_Member__c, so the Team_Member__c SObject is related to itself. The relationship represents a management ...
0
votes
1answer
31 views

aggregate soql select contact fields from opportunity query

wondering if anyone can help me with a query on opportunity that contains contact fields. i've tried a bunch of solutions but no luck yet. Select count(Id), Account.Contact.SomeField from ...
0
votes
1answer
42 views

SOQL query date condition?

I need a where clause on task..where its calculates the count of tasks every week between Friday and Thursday.. I know it will be a Aggregate query.I am confused how to calculate every-week..What ...
2
votes
2answers
86 views

Display an aggregate result on a visualforce page

I try to display on my visualforce page the result of a soql query (an aggregate result precisely). Here is my controller (a partof it) : public List<AggregateResult> somme {get; set;} public ...
2
votes
1answer
33 views

Querying distinct logins using LoginHistory and COUNT_DISTINCT

I seem to have run in to a SOQL error that I'm hoping someone has solved before. I am creating a dashboard for UserLogins using the LoginHistory object The query I am trying to run is: SELECT ...
0
votes
0answers
35 views

Opportunity analyze

I need an analyze of our opportunities for each team in our org. First I select the team and then should the visual page show a table of all accountOwner of this team and the different recordtypes ...
0
votes
1answer
17 views

Counting query results and displaying them in visualforce

I'm trying to count the number of each asset for an account and I'm not sure where I'm going wrong. I'm getting this error "Content cannot be displayed: Invalid field quantity for AggregateResult". ...
3
votes
1answer
119 views

For loop run just once

I have seven different recordtypes, but it seems that the first "for" (FOR (RecordType RType : RTypeList) loop run just once. The debug log show that the sql find 7 rows. 09:22:47.089 ...
2
votes
1answer
37 views

Put AggregateResult in Map

I'm trying to put my AggregateResult in a map so that I can reference it later in my code. trigger NoOfLiveProducts on Account (after insert, after Delete, after update) { map<Id,Integer> ...
1
vote
1answer
146 views

Convert aggregate result to decimal

I need to fetch the AggregateResult 'sett' for each Opportunity in a loop, from a map and convert them into decimals. I've seen Ariel's solution on this post but when I use it, it causes an error ...
2
votes
1answer
107 views

SOQL Aggregate calculation error due to multi-currency

I'm trying to calculate the SUM of all values in my Target__c field, on my Target__c custom object. When the below code is executed, my debug log shows that updatedTargets contains the correct target ...
1
vote
1answer
83 views

Help displaying aggregate results in footer of pageblock table

I am trying to create a Visualforce page to display a list of related records (lookup relationship) in a PageBlockTable. I would like to include a footer row that displays the sum of one of the ...
3
votes
2answers
98 views

What is the coalesce() eqivalent?

Much like this post here: SOQL: Avoid count with NULL results return 0 (zero) instead I have an instance where I am using aggregate functions like COUNT() and MAX() on a collection of Opportunities. ...
2
votes
2answers
88 views

SObject Exception: Invalid field for Opportunity

I am attempting to set a flag on the Opportunity Header based on an Aggregate Query of the Opportunity Line Item object, and I keep getting an SObject Exception. My code and the error log are below, ...
1
vote
1answer
58 views

Apex Trigger to Sum field using button

I have 2 custom object(Master Contract and Contact Person), i have lookup relationship between them. I have related list Contact Person in Master Contract Object with button named Recalculation. In ...
1
vote
1answer
60 views

how to do sum in soql?

Double sumOfPrice = 0; for(AggregateResult ar : [Select Id,Name, SUM(ProductPrice__c) totalUnitPrice from Inventory__c where OppLineItemId__c = ...
1
vote
2answers
28 views

Grouped Query Call

I'd like to display a short table of Users and their Activities. I can get to the id but when trying to display the username I run into grouping issues or relationship issues. Here's my class: public ...
0
votes
0answers
28 views

how many aggregate functions can be used in the SOQL query?

I am trying to write a grammar for parsing a SOQL query and while doing that I faced a problem where I need to find the maximum number of Aggregate functions (SUM (FieldName), COUNT (FieldName),... ...
4
votes
3answers
81 views

SOQL: Returning results where detail (M-D) count is at least 5

I'm trying to set up a query that will return which contacts have over 5 deals with us. We have a custom sObject which is (terribly) named, contacts_deals__c which serves as an intermediary table ...
0
votes
1answer
87 views

Create new records using Visualforce action and AggregateResult

I have a need to aggregate values from child records, group them by an Id field on that record and then create a new record for each corresponding ID. I have 2 objects, Sesaco_Contract__c and ...
0
votes
0answers
74 views

Currency Conversion Issue

I am working on a OptyLineItem trigger that does a rollup summary on the Opty header of a custom currency field on the OptyLineItem. The default currency is USD and Advanced Multi-currency is ...
3
votes
5answers
122 views

How to I use SOQL to aggregate values and only return the largest sum?

I want to do something like this, but you can't nest these particular functions: select max(sum(Number__c)), User__r.Name, Category__c group by User__r.Name, Category__c If my result set ...
0
votes
1answer
43 views

Aggregated Results Unknown Property

I have the following code but the aggregate-result doesn't work. I pretty much want to return back the number of active users in the system. How do I return the Count(*) of all the active users? Class ...
1
vote
2answers
79 views

Showing totals in custom page using SOQL

I have a custom object which requires booleon values which are attached to contacts like the following: Contact Option1 Option2 Option3 ============================================ Bob ...
1
vote
2answers
45 views

How to validate aggregate on child records

I have an object, lets call it Bill__c, that has a related list containing Contacts. In this relation each of the Contacts can be assigned a percentage of the total fee due on the Bill__c. I'd like ...
4
votes
2answers
260 views

How can you aggregate a checkbox field with SOQL?

I need to get the average completion of a task which is recorded using a checkbox field. Since that is stored as TRUE and FALSE instead of 1 and 0 it's proving a bit difficult. I would have liked to ...
3
votes
2answers
778 views

How to sort Wrapper class?

Am working with Aggregation on an object and i have specified count field in Order By Clause. Am loading aggregate results into wrapper class. Here am not getting the values in specified order. In ...
1
vote
2answers
130 views

Aggregate query does not support queryMore() [duplicate]

I have a requirement to send mass emails to certain Users of current day created records daily. I am unable to do that with below code. Getting error : Aggregate query does not support queryMore() ...
1
vote
1answer
1k views

Getting error “System.LimitException: Too many query rows: 50001” what i do in this case.

i tried below resolutions but no any worked... REsolution: If your controller does not have any DML operation than you can easily solve above two salesforce governer limits using the attribute ...
9
votes
1answer
194 views

Group by Rollup: Visualforce Remoting Exception: Too many query rows: 1000001

I have 557,029 Foo objects in my org. I want to count how many of each kind of picklist value there are within these: Type 1 - 100,000 Type 2 - 60,000 Type 3 - 40,000 Type N - N I thought I could ...
4
votes
3answers
431 views

Using Aggregate SOQL With Large Amounts of Data (> 500k records)

I am facing a issue about aggregate soql. My basic data object more than 500,000 record. But, i want to aggregate this object data. When i execute following data, SFDC will report the error for me. ...
2
votes
1answer
177 views

Grouped Query Cannot Use Child Relationship in Remote Action Apex Class

I am trying to count the number of account names that occur in my soql statement. Ultimately I have a map that shows all of the accounts near a technician and I want to show the number (count) of ...
2
votes
2answers
73 views

SOQL, how to return highly organized data

This may be a long shot, so bear with me. I have a query that returns a list of catagores (text strings) and a count of the number of times they occur: Order Request,7842 Request,3976 Other,3247 ... ...
2
votes
1answer
253 views

SOQL Query to count only Accounts with Opps in both this year and last year?

So rather than create an Apex class, run multiple queries then write some code to figure out the answer, I thought I'd take a stab at writing a complex query that would get me the answer I'm looking ...
3
votes
2answers
891 views

Grouping in Visualforce Charts

I have created a visualforce charting barSeries and it renders the results that I want aside from products with values of zero for the month. The chart is a repeat business report that is meant to ...
0
votes
1answer
194 views

Cross-tabular Report based on GROUP BY CUBE Result

Based on Salesforce Documentation here , we may create cross-tabular report from the query result. I've managed to create the class so far to show the aggregate result. Apex Class public class ...
3
votes
1answer
441 views

Most efficient way to transform AggregateResults to String, Object Maps

Question: What is the most efficient way to transform aggregate results to string object maps? Constraints: The keys of the aggregated results are unknown. The transformation has to be performed as ...
2
votes
3answers
848 views

Issue processing data from aggregate result query

I have a master-detail relation ship where I am updating the parent (lets call it Parent__c) based on its child records aggregated values (lets call the child, Child__c). The child has a relationship ...
1
vote
1answer
521 views

Help with Aggregate Result in Batch Apex

I received some help with this on the Salesforce forums but I can't get over the hump and get it working. The code below saves fine and I'm able to schedule it and it runs through all of the batches. ...
0
votes
1answer
201 views

Problem with AggregateResult

My Rolluputility: public class RollUpSummaryUtility { //the following class will be used to house the field names //and desired operations public class fieldDefinition { public String operation ...
0
votes
1answer
280 views

Better SOQL Query or Ability to Parse Results by Field

I have two objects: OBJECTA ID Description Cost Price SKU OBJECTB ID Qty SKU Essentially, the SQL version of my query would be: SELECT A.Description, A.Cost, A.Price, A.SKU, SUM(B.Qty) FROM A ...
1
vote
1answer
183 views

AggregateResult Count help

Sorry to bother you on a Saturday, but i need some help This is a two part question, so please be patient .I have created a fieldset on the account object called “HistoryTracking”. 1) I would like ...
-2
votes
1answer
645 views

Soql using MAX query [closed]

We are querying max value among certain field values of same data type from an object. we cant form perfect query . could anyone help to get perfect query.
3
votes
2answers
726 views

Remote Objects and Aggregate Function

Is it possible to call count() with remote objects?
4
votes
1answer
322 views

AggregateResult for a multi-select picklist

I am doing an AggregateResult SOQl query on different picklists on a Contact. List<AggregateResult> results = [select LeadSource, COUNT(id)cnt from Contact where LeadSource != null group by ...
2
votes
2answers
715 views

want to achieve rollup summary(SUM) using Aggregate functionss

Compile Error: Expression must be a list type: SOBJECT:AggregateResult at line 7 column 36 (this is line no7:manu.Total_Cost__c = Decimal.valueOf(ar[0].get('total'));) trigger rollupfldsonManuf on ...
10
votes
3answers
2k views

System.QueryException: Aggregate query does not support queryMore()

I am trying to deploy around 80 Components which include Apex Class,Trigger and Visualforce Pages. But it is failing due to below exception, MyTrigger: execution of BeforeInsert caused by: ...
0
votes
3answers
3k views

how to use logic with aggregate result

here i created one code which will retrieve record from "Account" object and create records in "abc" object based on selected fields. i used "AggregateResult" to add numbers with current year and ...