title: Postgres - Get sum of the values in a column on condition of another column
body: <p>I have a table in Postgres (<code>custdata</code>) that looks like this:</p>
  
  <pre><code>customerid | mID | count
      1         3      13
      1         2      17
      1         2       3
      1         5      14
      1         4       7
  </code></pre>
  
  <p>And a query like this:</p>
  
  <pre><code>SELECT
  c.customerid,
  c.mID,
  c.count,
  SUM (c.count)
  FROM custdata c
  JOIN tableB b
  ON b.customerid = c.customerid
  WHERE c.mID &lt;&gt; 2
  AND b.starttimestamp = ? and b.endtimestamp = ?
  </code></pre>
  
  <p>I want to get the sum of the values in the <code>count</code> column of the values whose <code>mID</code> does not equal 2. In this case, the correct sum would be 34. But in my case, the result is returning 2 different rows with the incorrect sum. How can I get the sum of the values in the <code>count</code> column where the <code>mID</code> is not 2? Any help would be appreciated.</p>