title: How can I use a Google Spreadsheet query to sum rows in another sheet
body: <p>I have a Google Spreadsheet that spans 3 (work)Sheets.
  On the first page I have a set of rows with customer data.</p>
  
  <p>That looks like </p>
  
  <pre><code>C      D    E
  Joe    -    100
  Bob    -    200
  Joe    -    300
  Jane   -    50
  </code></pre>
  
  <p>And on sheet 2 I have a column with a formula that attempts to query those values and sum the purchase values for each customer (col E).</p>
  
  <p>The formula I tried to use which fails is: </p>
  
  <pre><code>"=(QUERY('data'!B40:E60, "Select C, Sum(E) where C contains """&amp;A18&amp;""" Pivot C"))
  </code></pre>
  
  <p>In all seriousness though I really don't care about selecting C this is just the 20th variation I tried. What I am trying to do is sum E for all rows where C matches the cell A18 which is the customer name on sheet 2.</p>