• Mike Dwyer 9
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
This may be buried somewhere in the forum, but I cannot tease out the answer to my situation. I apologize for any - uh - duplication.

We have a custom sObject in our org. Records created in 2015 have been found to have a duplicate Name value. That is, two distinct records, with different Id values on each, both have the same Name value. Name, for what it's worth, is an AutoNumber field.

I can query both records into the Developer Console query results, but I cannot change the Name value. How can I make the Name as unique as the Id?

Second question: How can I find other similar duplicates? In SQL, I would use SELECT Name, Count(Id) FROM LOIS_Offender__c GROUP BY Name ORDER BY Count(Id) DESC, but SOQL says, "field 'Name' can not be grouped in a query call". 
It has been several months since I have had time to access Trailhead. Now I want to pick up where I left off. Every account that I might have used before wants me to "Tell us a little about yourself" so you can "tailor your learning journey." I interpret that to mean the login I just used is not what I previously used for Trailhead. Or did Trailhead drop me for inactivity?

How can I get connected back to my previous learning path, badges, and points?
It has been several months since I have had time to access Trailhead. Now I want to pick up where I left off. Every account that I might have used before wants me to "Tell us a little about yourself" so you can "tailor your learning journey." I interpret that to mean the login I just used is not what I previously used for Trailhead. Or did Trailhead drop me for inactivity?

How can I get connected back to my previous learning path, badges, and points?
This may be buried somewhere in the forum, but I cannot tease out the answer to my situation. I apologize for any - uh - duplication.

We have a custom sObject in our org. Records created in 2015 have been found to have a duplicate Name value. That is, two distinct records, with different Id values on each, both have the same Name value. Name, for what it's worth, is an AutoNumber field.

I can query both records into the Developer Console query results, but I cannot change the Name value. How can I make the Name as unique as the Id?

Second question: How can I find other similar duplicates? In SQL, I would use SELECT Name, Count(Id) FROM LOIS_Offender__c GROUP BY Name ORDER BY Count(Id) DESC, but SOQL says, "field 'Name' can not be grouped in a query call". 

Hello All,

 

I have the below aggregate Results query which is working fine.

 

public List <AccountPDF> getAccountsSnapshotYearly(){

    AggregateResult[] groupedResults = [SELECT Customer_Name__c,MAX(Segment__c),SUM(Load_Count__c) FROM Snapshot__c GROUP BY Customer_Name__c ORDER BY Customer_Name__c ASC];
       
        for (AggregateResult ar : groupedResults)  {
                                   
            snapshotResult.add(new AccountPDF(String.valueOf(ar.get('Customer_Name__c')), String.valueOf(ar.get('expr0')), String.valueOf(ar.get('expr1'))));
        } 
     return snapshotResult;
        
    }

 

The result of the above code is something like this.  Grouped and ordered by Customer Name.

 

Customer Name      Max(segment)             sum(load count)

ABC                                          7                                    40

XYZ                                           3                                    10

CAB                                          2                                    30

QWE                                        9                                    20

 

Now I want to order/sort this table by Sum(load count) - Should display in this order 10, 20, 30, 40 of load count. not in customer name order.

 

But when I include that 'ORDER BY Load_Count__c' in the aggregate result query, it throws error - Ordered field must be grouped or aggregated: Load_Count__c.  The Load_Count__c field is already aggregated in the query but still it shows the same error. 

 

Cant we order by an aggregated field?

 

Any other alternatives available?