Query parents, based on children ratio / percentage

Hi,

I have an index with a parent-child relationship.
What i basically wan't to do is to query with an percentage, let's say we have users and a list of transactions.

Parents:
{
"id": 1,
"name": "Eric"
},
{
"id": 2,
"name": "James"
}

Children:
{
"parent": 1,
"shopping_place": "Norway",
"trans_id": 11
},
{
"parent": 1,
"shopping_place": "Cuba",
"trans_id": 22
},
{
"parent": 1,
"shopping_place": "Cuba",
"trans_id": 33
},
{
"parent": 1,
"shopping_place": "Cuba",
"trans_id": 44
},
{
"parent": 2,
"shopping_place": "Norway",
"trans_id": 55
},
{
"parent": 2,
"shopping_place": "Cuba",
"trans_id": 55
}

Let's say i want to find all parents which has at least 25% of total child-transactions done in norway, how would a query like that look like?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.