title: Returning two aggregates in a single Cypher query?
body: <p>I've been struggling some with Cypher in regards to taking the SUM of two values and finding the difference.  I have these two queries, which find the total sent and the total received of a node:</p>
  
  <pre><code>START addr = node(5)
  MATCH addr &lt;- [:owns] - owner - [to:transfers] -&gt; receiver
  RETURN SUM(to.value) AS Total_Sent
  
  START addr = node(5)
  MATCH addr &lt;- [:owns] - owner &lt;- [from:transfers] - sender
  RETURN SUM(from.value) AS Total_Received
  </code></pre>
  
  <p>Basically my question is - how do I combine these two separate queries so I can take the difference between Total_Sent and Total_Received?  I have tried multiple start points like so:</p>
  
  <pre><code>START sendAddr = node(5), receivedAddr = node(5)
  MATCH sendAddr &lt;- [:owns] - sendOwner - [to:transfers] -&gt; receiver, receivedAddr &lt;- [:owns] - receiveOwner &lt;- [from:transfers] - sender
  RETURN SUM(to.value) AS Total_Sent, SUM(from.value) AS Total_Received, SUM(to.value) - SUM(from.value) AS Balance
  </code></pre>
  
  <p>But the Total_Received is null!  To me this looks like a pretty simple use case - what the heck am I doing wrong?</p>