cypher - Neo4j apply order to collect function -


i have data follows

node - student node - exam relationship (student)-[:given]->(exam) 

here 1 student has given multiple exams. need fetch last 3 exams of users

i have done somthing -

match (s:student)-[:given]->(e:exam) return id(s) student_id, s.name student_name, collect({exam_id:id(e), mark:e.marks,  exam_date:e.examp_date}) 

it fetch data me but, need exam ordered exam_date , there should limit can last 3 exams

i expecting done in single query

please comment here if more explanation needed.

thanks

try this

match (s:student)-[r:given]->(e:exam) s,r,e order e.exam_date desc return id(s) student_id, s.name student_name, collect({exam_id:id(e), mark:e.marks,  exam_date:e.examp_date})[0..3] 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -