# Aggregation and percentage

Hi,
Using the wikipedia sample data, I have the following query:

{
“queryType”: “groupBy”,
“dataSource”: “wikipedia”,
“granularity”: “day”,
“dimensions”: [“cityName”,“countryIsoCode”
],
“intervals”: “2016-06-27T00:00:00.000Z/2016-06-27T23:59:59.000Z”,
“filter”: {
“type”: “selector”,
“dimension”: “countryIsoCode”,
“value”: “FR”
},
“aggregations”: [
{
“type”: “count”,
“name”: “total”
}
]
}

It returns for a given day, the number of entries for a city (for cities in France). What I would like to have is the percentage of entries as well. This is obtained by dividing the total (from the aggregation) by total of all entries. That total is the result of:

{
“queryType”: “groupBy”,
“dataSource”: “wikipedia”,
“granularity”: “day”,
“dimensions”: [“countryIsoCode”
],
“intervals”: “2016-06-27T00:00:00.000Z/2016-06-27T23:59:59.000Z”,
“filter”: {
“type”: “selector”,
“dimension”: “countryIsoCode”,
“value”: “FR”
},
“aggregations”: [
{
“type”: “count”,
“name”: “total”
}
]
}

Can this be achieved?
Thanks - Christian

Hmmmmmm… I think because you need to SUM the results first, and then divide, you will need to use a subquery?

Did anyone ever figure this out? A subquery is a good place to start, but how do I combine the queries in a way that makes sense?

What query type do I use for the outer query? If I use groupBy or topN, I will not receive all rows from the original query. But if I use time series, how do I get the sum of all counts?

If I calculate the sum of all counts in the inner query, how do I access the original data in the outer query?