What I am trying to do is to get the MAC of all these values for the field “hr”, For some reason, I could not flatten or unnest these objects.
In addition, would be great to be able to count the number of times we have the field “hrt” with the value between x and y where the “hr” is larger/smaller than a certain value.
SELECT MAX(ARRAY_MAX( ARRAY v.hr FOR v WITHIN {d} WHEN v.hr IS NOT NULL END)) AS max,
SUM( ARRAY_COUNT(ARRAY 1 FOR v WITHIN {d} WHEN v.hrt BETWEEN 10 AND 20 AND (v.hr < 50 OR v.hr > 1000) END) AS cnt
FROM default AS d;
@vsr1 do you think it is possible to also get the path somehow?
so if this
MAX(ARRAY_MAX( ARRAY v.hr FOR v WITHIN {d} WHEN v.hr IS NOT NULL END)) AS max
get the maximum from let’s say the first object, to also get the path to that, like in this case if 471 is the highest rank, the path would be: " r - a - aa - bb - 3" . Could this be possible, or at least a part from it?( I think I would be interested in the “bb” part)
do you think would be possible to get the path if I now the value of hr?
like for example if the hr is 244 to get something like b - aa - cc - 14? or at least just this array?
The reason I am asking this is that these arrays tend to be very big, like thousands of entries (same depth) and to get these and then iterate through them is a waste of bandwidth and CPU power.
Now, because I have the min of hr, I could try somehow to use that to identify the path. What do you think?
Also, one more question, regarding your recommendation query: MAX(ARRAY_MAX( ARRAY v.hr FOR v WITHIN {d} WHEN v.hr IS NOT NULL END)) AS max
do I still need to use the MAX in front of ARRAY_MAX, or is enough that I have the ARRAY_MAX?