简体   繁体   中英

order based on two nodes in neo4j

In neo4j i want to order the results based on ContactId and LookedupStatus in descending order.

This query orders the results based on ContactId only

   MATCH (p:Contact)<-[:RELATIONSHIP]-(d:GroupMember) 
   WHERE toint(d.GroupId) = 55 
   and p.EmailId<>''
   RETURN p
   order by toint(p.ContactId) desc

How to modify the above query so that it orders on both p.ContactId and p.LookedupStatus

You can combine the sort conditions:

UNWIND [ {a:3, b:2, c: 1}, {a:1, b:2, c: 2}, 
         {a:1, b:1, c: 3}, {a:3, b:1, c: 4} ] as n
RETURN n ORDER BY n.a DESC, 
                  n.b ASC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM