1

My question is slightly similar to this one:

I have a query that works fine:

select bank__r.id, min(processedDate__c)min from cashflow__c group by bank__r.id

and I want to add another field

select bank__r.name, bank__r.id, min(processedDate__c)min from cashflow__c group by bank__r.id

Idea there is to include the bank name associated with the most recent cash flow. I know I could accomplish this with two queries, first one like the above and a second one like "select name from bank__c where id=:someId" but it seems like I should be able to get that other field included more easily.

1 Answer 1

2

Since your query already groups by a UID, then aggregating the name field won't matter. In other words, the min(bank__r.name) and max(bank__r.name) will be the same, since no matter how many aggregated rows are returned, for each id the name will be the same.

1
  • Thanks a lot. That fixed it. Sort of looks like a bug in SOQL that it should be required though. Makes the intent of the query less obvious I think.
    – Andrew
    Sep 9, 2014 at 0:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .