the following N1QL works:
SELECT PreparedName,avg(ResultCount) FROM system:completed_requests
where PreparedName is not missing group by PreparedName order by avg(ResultCount);
but the following N1QL:
SELECT PreparedName,array_agg({"ResultCount":ResultCount,"ResultSize":ResultSize}) as Result FROM system:completed_requests
where PreparedName is not missing group by PreparedName order by PreparedName,ResultCount,ResultSize;
don’t work.
I want to aggregate ResultCount field group by PreparedName, and order by PreparedName first,and then order by ResultCount in Result array,last order by ResultSize in the Result array .
I also try this N1QL:
SELECT PreparedName, array_sort(array_agg({"ResultCount":ResultCount,"ResultSize":ResultSize})) FROM system:completed_requests
where PreparedName is not missing group by PreparedName order by PreparedName;
and I found the sort order is depend on the order of array_agg (ResultCount
> ResultSize
) Am I right?