The tag has no usage guidance.

learn more… | top users | synonyms

0
votes
1answer
16 views

Extract aggregratelist value where conditions are met

I need some continued help with this project. I have my aggregrateResult list with the needed data for every account. How do I pull the data just for the current account? global class ...
0
votes
0answers
16 views

Update Object with unique values from Child object using Aggregate result

I am trying to update a field on the Quote (Operational_Start_Date__c) from the results of an aggregate result query. The trigger runs on quote, queries QuoteLine for unique values and update the ...
0
votes
2answers
24 views

Illegal assignment from object to string Aggregate Result

I am getting an "Illegal assignment from object to string" on an Aggregate Result trigger. Here is the code snipped; List<AggregateResult> uniqueCountries = ([SELECT ...
0
votes
1answer
15 views

Multiple query aggregateResult

I am trying to find my way to wrap my head around this problem. I am trying to eliminate 3 of these for AggregateResult loops and just make one since it is getting the same object. I am a new ...
1
vote
0answers
19 views

SOQL query aggregation

I need to provide statistics to the users in my VF Page, showing the total of records they own where the status is New, In progress, Approved, Pending, Converted I have tried the below query in my ...
1
vote
2answers
47 views

SOQL - Where iD not in aggregate list

I can't quite get the syntax right on this. I need the query under getAllBadges, last public of code, to exclude any badges found in the aggregate function. However I can't figure out the name of ...
1
vote
2answers
36 views

How to sort when we use aggregate function?

I have a formula field that orders a particular field values. Example: A field for employees profession, for each profession there is an equivalent number value like, "IT = 1, Doctor = 2". I'm using ...
0
votes
1answer
24 views

soql aggregate query has issue returning id of record

i want to query the opportunities for a using a set of account ids and get the opportunity for each account that has the most recent start_date__c. so im grouping the opportunity query on account and ...
1
vote
1answer
27 views

Why does SalesForce aggregate query discards two last digits?

I have created a simple object called Object__c. Also Number field (18,0) I have created for this object called Number__c. Then I have created one record with name 'x' and Number__c value of '111 111 ...
4
votes
1answer
79 views

Apex aggregrateresult error

Any help why I'm unable to add this? List<AggregateResult> revenue = [select SUM(Daily__c) rev, Client__r.Name from Commissions__c]; Integer totalMonthlyRevenue = 0; for ( AggregateResult i ...
0
votes
1answer
30 views

Working off the Quote in Visualforce, how can I access Contacts? Getting an unsupported complex expression error

The quote is associated with an account, and the account has contacts. I can access the account data just fine, but when I try to display any contact data then it fails with the following error: ...
0
votes
0answers
18 views

Join two aggregate results with mutually exclusive records

I have below two Aggregateresults where I need all the records that come in query results whether Rep_abv__c(of Compliance_Incidents_abv__c) and Id (of User) matching or not so that I can keep all ...
1
vote
1answer
90 views

Find AggregateResult Fields Dynamically

I ran across some code a while back to find fields within an AggregateResult dynamically to do some processing irregardless of what was in it. AggregateResult results = [SELECT ...
1
vote
1answer
37 views

Can an aggregate function be in SOQL where clause?

Can an aggregate function be in SOQL where clause? Looks like it cannot but I can't find anywhere a documentation a clear answer if it is forbidden and why if it is
9
votes
1answer
181 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
65 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
105 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
51 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
120 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 ...
3
votes
2answers
560 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
68 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
38 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
75 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
127 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
194 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
2answers
434 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
231 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
251 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
205 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
303 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
2answers
233 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
168 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 = ...
2
votes
2answers
40 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
31 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
98 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
122 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
109 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
238 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
54 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
85 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
58 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
411 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
1k 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
158 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
227 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
652 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
211 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
77 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
351 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 ...