I need query on Case and its child object 'Case Status History' such that I need cases whose Status='closed' and I need the latest 'Case Status History' record for each case. The 'Name' field of 'Case Status History' record is of Autonumber type so I am trying to get the largest name records of 'Case Status History' for each case. I was trying the bellow query but its not working.
Select Id , Subject , Status ,
( Select Id,Name,parent_case__r.subject
FROM Case_Status_History__c
where isdeleted = false group by name DESC limit 1 )
FROM Case where Status ='Closed'
Is it possible to get records by SOQL in the way I want ?
Thanks!
group by name
from inner query.. I guessCase_Status_History__r
so your inner query will be likeSelect Id , Subject , Status , ( Select Id,Name,parent_case__r.subject FROM Case_Status_History__r where isdeleted = false DESC limit 1 ) FROM Case where Status ='Closed'