title: Is there a way to get sum of field with a condition like WHERE (SQL) in MongoDB
body: <p>I'm looking for a way to get sum of a field in my mongodb. My DB looks like this:</p>
  
  <pre><code>{
      "_id" : ObjectId("553f35b8bfabe235158b4f4b"),
      "event_id" : NumberLong(342),
      "ticket_id" : NumberLong(85326),
      "ticket_code" : NumberLong(3445345345343),
      "ticket_type_id" : NumberLong(42),
      "ticket_created" : NumberLong(1429866042),
      "ticket_deleted" : NumberLong(0),
      "ticket_user_id" : NumberLong(3207),
      "ticket_used" : NumberLong(0),
      "order_id" : NumberLong(6988),
      "order_code" : NumberLong(444234),
      "order_created" : NumberLong(1429866042),
      "order_deleted" : NumberLong(0),
      "order_sales_pipeline" : NumberLong(1),
      "order_invoice_id" : NumberLong(4194),
      "order_invoice_amount" : 25000.0000000000000000,
      "order_invoice_created" : NumberLong(1429866053),
      "order_invoice_deleted" : NumberLong(0),
      "order_invoice_code" : NumberLong(419338),
      "payment_id" : NumberLong(4355),
      "payment_amount" : 25000.0000000000000000,
      "payment_currency" : NumberLong(2),
      "payment_author_id" : NumberLong(159),
      "payment_type_id" : NumberLong(2),
      "payment_created" : NumberLong(1429866053),
      "payment_deleted" : NumberLong(0),
      "create_time" : ISODate("2015-04-28T07:24:40.289Z")
  }
  </code></pre>
  
  <p>I need to get sum of <code>payment_amount</code> field with conditions, I'd this in SQL like this:</p>
  
  <p><code>SELECT SUM(payment_amount) as total FROM ticket_cache WHERE event_id = 342 AND ticket_type IN(84, 45, 365)</code></p>
  
  <p>Is there a way to the same in mongodb?</p>