title: Migrating to MongoDB: how to query GROUP BY + WHERE
body: <p>I have a MYSQL table with records of people's names and the time of arrival expresed as a number. Think of it as a marathon. I want to know how many people arrived into a certain gap of time who where named the same, so:</p>
  
  <pre><code>SELECT name, COUNT(*) FROM mydb.mytable
  WHERE Time&gt;=100 AND Time&lt;=1000
  GROUP BY name
  </code></pre>
  
  <p>And as results I get:</p>
  
  <pre><code>Susan, 1
  John, 4
  Frederick, 1
  Paul, 2
  </code></pre>
  
  <p>I'm migrating to MongoDB now, and using Python to code (so I'm asking for Pymongo help). I tried looking for information about the GROUP BY equivalent (even when I have read that NoSQL databases are worse at this kind of operation than the SQL ones), but since they released the new agreggate API, I hjaven't been able to find a simple example like this solved with the group method, the Map-Reduce method or the brand new agreggate API.</p>
  
  <p>Any help?</p>