Double limit query

I’d like to do a double limit on a group by query

something like show tuples (A,B), limit values of A to 3 distinct values and for each of those values limit the values of B to 2 distinct values.
so I’d like to see results of the sort
(A1, B1_1)
(A1, B1_2)
(A2, B2_1)
(A2, B2_2)
(A3, B3_1)
(A3, B3_2)

the query might be something like
“queryType”: “groupBy”,
“dataSource”: “mydata”,
“intervals”: ['2021-10-10/2022-10-10"],
“granularity”: “all”,
“dimensions”: [“field_a”, “field_b”],
“limitSpec” : {
“type”: “default”,
“columns”: [
“direction”: “descending”,
“limit” : 3
“direction”: “descending”,
“limit” : 2

Is there a way to do this?


what is the relation between A and B?. You will most likely need to get B in an inner query and join to get A.