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
NikunjVadiNikunjVadi 

query help

time__C is child object and account is parent object , i want to add hour__c field of time__c . 
i am activating trigger when any time record is created.
but i am getting error executing this query
Time__c tl = [select Time_Account_Mapping__c from Time__c order by LastModifiedById desc limit 1];
	
    Integer x = [select sum(Hours__c) From Time__c where Time_Account_Mapping__c in  (select Time_Account_Mapping__c from Time__c order by LastModifiedById desc limit 1)];


Error : expecting a right parentheses, found 'order'
YuchenYuchen
The error shows because in the inner query, we cannot have order by and limit, so "order by LastModifiedById desc limit 1" should not be in the inner query. In fact, for inner query, you can not query for the same Object as the outer query. So maybe you can directly querying for the Time__c to get the sum, something like this:

select sum(Hours__c) From Time__c