title: How to get SUM of all CouchDB values?
body: <p>How to extract SUM depending on ID or something, with goal of getting SUM of all values?
  <br/><br/> I am able to get all values but canot SUM beacouse its a single variable, so there must be some kind of segmentation to SUM them?? any ideas?</p>
  
  <pre><code>$db = $.couch.db("fuel");  
  
  function refreshFuel() {  
  
  $("div#fuel").empty();  
  
  $db.view("fuel/bill", {success: function(data) {  
  
      for (i in data.rows) {  
      id = data.rows[i].id;  
      bill = data.rows[i].key;  
      date = data.rows[i].value;  
  
      html = '&lt;div class="fuel"&gt;' +  
     '&lt;span class="bill"&gt;' + bill + '&lt;/span&gt; ' +  
     '&lt;span class="date"&gt;' + date + '&lt;/span&gt; ' +    
     '&lt;/div&gt;';  
  
    $("div#fuel").append(html);  
   }  
   }});  
  }  
  
  function getAll(){
  
  $("div#all").empty();  
  
  $db.view("fuel/bill", {success: function(data) {  
  
      for (i in data.rows) {  
      id = data.rows[i].id;  
      bill = data.rows[i].key;  // how to get SUM of all this values
      date = data.rows[i].value;  
  
      html = 
     '&lt;span class="all"&gt;' + bill + '&lt;/span&gt; '     
  
  
    $("div#all").append(html);  
   }  
  }});
  
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>my JSON looks like this:</p>
  
  <pre><code>    {
     "_id": "1a06982d3434f37a04a02dbf360010ee",
     "_rev": "1-c8c9d5252a76abd8f565ff82bf63b0e8",
     "value": "200",
     "date": "2011-09-05T10:28:55.101Z"
  }
  </code></pre>
  
  <p>and my VIEW look like this:</p>
  
  <pre><code>function(doc) {
      if (doc.value, doc.date) {
          emit(doc.value,doc.date, doc);
      }    
  }
  </code></pre>