title: Calculate percentage in mongodb
body: <p>My db looks like:</p>
  
  <pre><code>{
    {user:bob,votes:63}
    {user:jack,votes:27}
    {user:john,votes:10}
  }
  </code></pre>
  
  <p>I can get the total of the votes, but I can't figure out how to get each persons vote as a percentage of the total. For example; jack would have 27% of the vote.</p>
  
  <pre><code>[ 
    {
      '$group': { 
                  '_id': '',
                  'totalofvotes': {'$sum': '$votes'},
                  '%votesperperson': {'$multiply':[{'$divide':["votes",{'$sum': '$votes'}]},100]}                   
                },
    }
  ]
  </code></pre>