for $x in $results let $count := $x[1]
Perhaps you want
$x(1)
here to access the first item in the array $x?
Yes. ‒ Thanks that you pointed a typo out.
Thus I adjusted the member access specification. But I stumble on the message “[XPTY0004] Item expected, sequence found: (1, 1, 1)” from the query evaluation.
Which script fine-tuning will help then?
Regards, Markus