MATCH (room:/hxyy/room) -[:room_personnel_info_to_person_job_number*1..1]-> (person:/hxyy/person WHERE department is not null) RETURN DISTINCT room.id AS "room_id", person.department AS "person_department", _.path order by "person_department","room_id" /** timeout(5m) output() **/ ; MATCH (room:/hxyy/room) -[:room_personnel_info_to_person_job_number*1..1]-> (person:/hxyy/person WHERE department is not null) RETURN DISTINCT room.id AS "room_id", person.department AS "person_department" INTO /temp_room_person_e6820088-9996-48ab-a500-7b928a17783d WITH TIMEOUT = 6m /** timeout(5m) output() **/ ; select room_id, person_department from /temp_room_person_e6820088-9996-48ab-a500-7b928a17783d order by room_id, person_department /** timeout(5m) output() **/ ;