Extracting nodes with maximum size field property


Hello everyone,

I’m struggeling on another quite simple query. If I have nodes with an field property within and I want to find the ones having the most elements in their field. How do I do that?

I tireid:

select name, myfield.size() from mynode 
where myfield.size() = (
select max(myfield.size()) from mynode)

That’s not working. Subquery is working fine if used alone and query is working fine if I leave out the where part and use it alone. It also works fine if I put a fix number instead of the subquery behind, but that’s not what I want. Also Order by and Limit is not an option if you have multiple nodes with the same amount of field elements it cuts out the others.

Also I tried to solve it with Let:

select name, myfield.size() from mynode let $max = (
select max(myfield.size()) from mynode) 
where myfield.size() = $max

But that’s not working either. I don’t get why that’s not working. I’m using Version 3.0.8 and the Studio.

Would be glad if someone could tell me how to do that correctly. Thank you so much!


Hi @Petey123,

can you share an example of your structure? What kind of type of field myfield is? What does it contain?



Hey @mbonizzi

Each Node has a name and a field full of strings. F.e. Yo have a Node with the props: name=“Homer Simpson” specials:[“dumb”, “d’oh”, “blue crayon in his nose”] and class character.

Do you need more of the structure? That’s just the node class. I’m trying to find the node(s) out of all nodes that has the most entries.

(the class “character” is what I wrote as “myclass” and the property specials is what I called “myclass” “myfield” up there, sorry my code was german so I tried to translate it somehow).