Ordering by text field in sub query

  • 6 January 2022
  • 0 replies
  • 1 view

In Doc Gen we are printing out mailing information, I have been asked to make it alphabetically sorted by a text field in a sub query. Using Order By in the sub query does not cause an error, but neither does it cause the final records to be sorted the way we would like. Trying to address the field I want to order by in the parent record causes errors no matter how I try to reference it (using the relationship name with and without the __r, plural or not plural does not matter).
Is there a way to do this with the current structure of the query?


Example of query, RSVP_Display_Name__c is the field that all records should be sorted on.

SELECT (Select id, RSVP_Display_Name__c, Address__c from RSVPs__r WHERE Outside_Event__c = '<<Outside_Event_Id>>' ORDER BY RSVP_Display_Name__c),
(Select id, Branch_Name__c from Company_contacts__r WHERE Primary_Company__c = True),
Name, Title, Company_Name__c FROM Contact Where Id in (Select Contact__c from RSVP__c WHERE Outside_Event__c = '<<Outside_Event_Id>>' AND Contact__c != NULL)
Repeat By: Table


0 replies

Be the first to reply!

Reply