My data is a series of document each with a time and a transaction id. I want to group the data by transaction id, from each group select the largest time and then use those times as input to a percentile function. I can get the list of times using the SQL style syntax like this
"query": "select time from (SELECT max("time") as time, count(*) as count, "transactionId" FROM "test-logs" group by transactionId) where count > 1)"
However when I try to calculate a percentile on that data like this
"query": "select percentile(time, 50) from (SELECT max("time") as time, count(*) as count, "transactionId" FROM "test-logs" group by transactionId) where count > 1)"
I get the error "Nested aggregations in sub-selects are not supported."
I have tried to find a way to do the same thing with the DSL but I have not been able to figure it out, could anyone suggest a way forward?