How to get null when use head funtion with a empty list in cypher?

Posted by PeaceMaker on Stack Overflow See other posts from Stack Overflow or by PeaceMaker
Published on 2012-10-23T05:29:03Z Indexed on 2012/10/23 17:01 UTC
Read the original article Hit count: 222

Filed under:
|

I have a cypher query like this.

START dep=node:cities(city_code = "JGS"), 
arr=node:cities(city_code = "XMN") 

MATCH dep-[way:BRANCH2BRANCH_AIRWAY*0..1]->()-->arr

RETURN length(way), transfer.city_code,
extract(w in way: w.min_consume_time) AS consumeTime

The relationship named "way" is a optional one, so the property named "consumeTime" will be a empty list when the relationship "way" not exsit.

The query result is:

| 0 | "JGS" | [] |
| 1 | "SZX" | [3600] |

When I want to use the head function with the property "consumeTime", it return a error "Invalid query: head of empty list".

How can I get a result like this?

| 0 | "JGS" | null |
| 1 | "SZX" | 3600 |

© Stack Overflow or respective owner

Related posts about neo4j

Related posts about cypher