function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
prasanth kumarprasanth kumar 

how to display 3rd level soql query in visualforce page.


hi, loan__c --> Transaction__c -->  customer__c  -->  loan is the grand child, transaction is child, customer is parent.
 
public list<customer__c> cus=[select id,name,(select amount__c,name,Transaction_Type__c,(select id from loans__r) from transactions__r) from customer__c];
Error: DYNAMICAPPROVALCLASS Compile Error: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object. at line 10 column 5

how to write this type of query . 
 
James WooleyJames Wooley
Would something like this give you what you want?
 
public list<transaction__c> transactions = [select amount__c, name, Transaction_Type__c, (select id from loans__r), customer__c, customer__r.Name from transaction__c];

Jeff Douglas has a useful blog on the different types of SOQL queries which may also help you:
http://blog.jeffdouglas.com/2010/02/22/soql-how-i-query-with-thee-let-me-count-the-ways/