title: Drupal views query using group by and sum
body: <p>I have thought about and played about with D7 views module for quite a while but I cannot get it working. </p>
  
  <p>What I want to simple group-by and sum use if you see SQL below:</p>
  
  <p>table</p>
  
  <pre><code>　　name　        age             sex
  
  　　Los　         20　             1
  
  　　San　         25　             0
  
  　　Lan　         30　　           0
  
      Bos　         23　            1
  
  　　mini          28              1
  </code></pre>
  
  <p>SQL:</p>
  
  <pre><code>　　SELECT sex,sum(age) FROM `msg_info` group by sex
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>　　sex       sum(age)　　
  
  　　0　　　　   55
  
  　　1　　　　   71
  </code></pre>
  
  <p>I have tried to use "aggregation" and "query setting"(distinct) to get the table like that But I just can't. There is a "pure distinct" query setting under "adanced" which showed only one row at the end. I thought that's going to help but not really.</p>
  
  <p>The real data has more columns than the example I gave here. Aggregation settings appeared be for every field which defaultly had a value being "group field result together". I had been playing with this. I set the "sum" for the field that I want to do SUM for. It's just no go.</p>
  
  <p>Maybe anyone can help? </p>