title: What is the literal expression of NaN in Neo4j Cypher?
body: <p>How do I express NaN as a literal in a Cypher query?</p>
  
  <p><strong>Situation</strong></p>
  
  <p>I have a NaN value in a database:</p>
  
  <pre><code>match (a) with max(a.CONCENTRATION) as m return m
  </code></pre>
  
  <p>will return </p>
  
  <pre><code>m
  ---
  NaN
  </code></pre>
  
  <p><a href="https://neo4j.com/docs/developer-manual/current/cypher/" rel="nofollow noreferrer">Cypher reference in Neo4j</a> mentioned that this is possible as the result of special value being stored:</p>
  
  <blockquote>
    <p>The special value java.lang.Double.NaN is regarded as being larger than all other numbers.</p>
  </blockquote>
  
  <p><strong>What I tried</strong></p>
  
  <p>However, now that it's in there, I don't know how to match them in search, because you get the following error</p>
  
  <p>input</p>
  
  <pre><code>match (a) where a.CONCENTRATION = NaN return a limit 10
  </code></pre>
  
  <p>error</p>
  
  <pre><code>Variable `NaN` not defined (line 1, column 35 (offset: 34))
  </code></pre>
  
  <p><strong>Other references</strong></p>
  
  <p><a href="https://neo4j.com/docs/developer-manual/current/cypher/" rel="nofollow noreferrer">Cypher reference in Neo4j</a> doesn't mention NaN literal, unless I missed it.</p>
  
  <p>I've googled 'Cypher NaN' but the closest thing I got is how to add inf/NaN, which wasn't directly addressed (<a href="https://stackoverflow.com/questions/26980830/how-to-add-infinity-nan-or-null-values-to-a-double-property-on-a-node-in-cyp">How to add infinity, NaN, or null values to a double[] property on a node in Cypher/Neo4j</a>).</p>