You need to sign in to do that
Don't have an account?
Vinay J
Aggregate query
Hi guys,
Auction is parent is Bid is the child object. Through insert/update trigger on bid, I want to update highest bid's amount and owner on Auction record. So basically, for a list of auctions(for which bids are created/updated), i want to fetch ownerid and amount values from the highest bid. Below mentioned query works perfect. But when I add ownerid to select, I get an error "Field must be grouped or aggregated: OwnerId"
Select auction__c, max(bid_Amount__c), from Bid__c where auction__c = 'a0617000000MR05AAG' or auction__c = 'a0617000000MR2TAAW' group by auction__c order by Max(bid_amount__c) desc
If I add ownerid to group by along with auction__c, it returns all the bids for the auctions. Please help.
Auction is parent is Bid is the child object. Through insert/update trigger on bid, I want to update highest bid's amount and owner on Auction record. So basically, for a list of auctions(for which bids are created/updated), i want to fetch ownerid and amount values from the highest bid. Below mentioned query works perfect. But when I add ownerid to select, I get an error "Field must be grouped or aggregated: OwnerId"
Select auction__c, max(bid_Amount__c), from Bid__c where auction__c = 'a0617000000MR05AAG' or auction__c = 'a0617000000MR2TAAW' group by auction__c order by Max(bid_amount__c) desc
If I add ownerid to group by along with auction__c, it returns all the bids for the auctions. Please help.
Shashank (Salesforce Developers)
In this case, it would be advisable to just write another separate query to fetch the ownerid.