title: PostgreSQL - Conditional aggregation - Avg() in Select statement
body: <p>I have this table</p>
  
  <pre><code>| user         | Mark       | Points   |
  |--------------|------------|----------|
  | John         |    0       |    2     |
  | Paul         |    5       |    3     |
  | John         |    4       |    4     |
  | Paul         |    7       |    5     |
  </code></pre>
  
  <p>I would like to build a query with one select statement that returns the rows shown below.
  Avg(Mark) - should be average only if Mark>0
  Sum(Points) - should be sum of all records.</p>
  
  <pre><code>| user         | Avg(Mark)  | Sum(Points) |
  |--------------|------------|-------------|
  | John         |    4       |    6        |
  | Paul         |    6       |    8        |
  </code></pre>
  
  <p>Can anyone point to a proper syntax? </p>
  
  <p>I believe it should like :</p>
  
  <pre><code>select user, avg(Mark&gt;0), sum(Points) from Table group by user;
  </code></pre>