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
JLeisseJLeisse 

Querying for multiple MAX values on child records

I have a child object of Contact, called Test, and I am trying to query (preferably 1 query) for the max value on three different fields (Math, Verbal, Writing). Here is the example I am working with:

Contact = Jeff
Test1 --> Math = 800, Verbal = 200, Writing = 300
Test2 --> Math = 600, Verbal = 800, Writing = 200
Test3 --> Math = 150, Verbal = 250, Writing = 750
Test4 --> Math = 123, Verbal = 656, Writing = 743

I want to write a SOQL query that would output:
Contact = Jeff, Math = 800, Verbal = 800, Writing = 750

I would like the MAX value for Math, Verbal, and Writing in one row. Is this possible? If not, would this be something you would typically roll up to the Contact? Or would you write a trigger to create a Master Test record?

Thanks!
JLeisseJLeisse
Just as an FYI, I am able to write three (3) separate queries to get this information. I'm trying to get this into one (1) query.