title: Query for SUM values on multiple columns, then substract and compare results
body: <p>I have the following scenario: 
  A Google Sheet to collect daily Cash Flow on two shifts (Morning and Afternoon), starting each shift with money on hand (cash) and money on bank account (to pay bills and make transfers as necessary).
  The circuit works by recording money IN or money OUT and using the direction of the flow as a basic selector, in order to determine by adding and substracting, how much money came in, and how much came out.</p>
  
  <p><img src="https://i.stack.imgur.com/oWPjy.png" alt="enter image description here"></p>
  
  <p>I've been testing with long <code>QUERY</code> formulae to try to come out with results, but so far, I managed to only filter by means of <code>SUM(X)</code>. However, I been trying after reading all documentation about Query Formula, to select and sum every income for every shift within the day, do the math, compare with the starting cash, and determine how much money by means of payment, date and shift came in or out.</p>
  
  <p>This is the Query formula for the collected items:</p>
  
  <pre><code>=QUERY(A1:Q,"SELECT A,B, SUM(G), SUM(H), SUM(I), SUM(J), SUM(K) WHERE E='Collected' AND L='Cash' GROUP BY A,B LABEL SUM(G)'Rentals Collected' ",2)
  </code></pre>
  
  <p>And this is the Query formula for the paid items:</p>
  
  <pre><code>=QUERY(A1:Q,"SELECT A,B, SUM(G), SUM(H), SUM(I), SUM(J), SUM(K) WHERE E='Paid' AND L='Cash' GROUP BY A,B LABEL SUM(G)'Rentals Paid' ",2)
  </code></pre>
  
  <p>I've also used this Query formula for displaying money available on hand at the start of each shift, for each day.</p>
  
  <pre><code>=QUERY(A:Q, "SELECT A,B,C,D WHERE C IS NOT NULL", 2)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/LBJ3v.png" alt="enter image description here"></p>
  
  <p>Any ideas?</p>
  
  <p>Here's a <a href="http://goo.gl/jCuUD9" rel="nofollow noreferrer">Dummy Sheet that recreates the scenario</a>.</p>