I couldn't find a similar post, so if you already know one or if my question is not the proper one, please let me know.
I have this query
MATCH
(t:Taxi {name:'Taxi1813'})<-[:ASSIGNED]-(u2:User)-[rd2:DROP_OFF]->
(g2:Grid)-[r:TO*1..2]-(g:Grid)<-[rd:DROP_OFF]-(u:User)-[:ASSIGNED]->(t)
WHERE ID(u2) < ID(u) AND rd2.time >= '04:38' AND rd2.time <= '04:42'
WITH DISTINCT u2, g2, u, g, rd2, rd
MATCH p=shortestPath((g2)-[r:TO*1..2]-(g))
WITH rd2, rd,u2, g2, u, g, p, REDUCE(totalTime = 0, x IN RELATIONSHIPS(p) | totalTime + x.time) AS totalTime
WHERE totalTime <= 4
RETURN u2.name, u.name
So at the end i got two columns
u2.name u.name
User179 UserTest
User177 User179
Is there is a way or function to merge both columns into a single one and remove duplicates
Users
User179
User177
UserTest
Any suggestions? Thank you
You can combine the two collections into a single collection and then return just the distinct items.
WITH ['User179', 'User177'] AS list1
, ['UserTest', 'User179'] AS list2
UNWIND list1 + list2 AS item
RETURN DISTINCT item
Alternatively, if you are using APOC you could use apoc.coll.union()
instead.
WITH ['User179', 'User177'] AS list1
, ['UserTest', 'User179'] AS list2
RETURN apoc.coll.union(list1,list2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With