I got a lot of nodes, some with similar values in field X
, I want to select by distinct X
values and take all the popular nodes (order by some other field Y
) with all their properties.
Example:
ID | X | Y | Name
1 | A | 100 | David
2 | A | 10 | Chris
3 | B | 5 | Brad
4 | B | 25 | Amber
Should return:
1 | A | 100 | David
4 | B | 25 | Amber
I managed to get the list by distinct X
:
MATCH (u:NodeType)
RETURN DISTINCT u.X
I need to find the most popular (highest value of Y
) nodes to join with my distinct nodes (which are now only a single property) and return whole nodes (with all the properties).