Niels_DJVB's avatar

Deep relation counter

Hey Community,

I've been trying to get a single query for a resultset and I've been having problems with counting on a deeper relation.

First off, I've got Product with OrderLines->Order->Customer->Address->Country. Now I'm trying to add a count of the amount of sales in a distinct country.

I can't think of a way to do this except for looping over it but I'd like to avoid making messy code. I'd at least like to know if this is even possible with a single or minimal queries.

0 likes
1 reply
vincent15000's avatar

I've had a similar problem and I solved it with flattening the result and then I have done the sum of the fields. But this will work only if the field you need to sum has a unique name among all the other fields in the result.

1 like

Please or to participate in this conversation.