title: How to use mongoDB $sum in @Query
body: <p>I'm new user of mongoDB, I have create an application with spring boot/mySql and I want replace database sql to mongoDB.</p>
  
  <p>I did change all things necessary for example, annotations, relations etc ... but I have a problem with request I don't know the similar syntax of @Query in mongoDb.</p>
  
  <p>this my request with sql:</p>
  
  <pre><code>// this calculate the sum of all distance in walk's document
  @Query("select sum(distance) from Walk")
  public Double sumDistance();
  </code></pre>
  
  <p>I did read mongoDB aggregate and I know how to use it in console windows with command </p>
  
  <pre><code>$ mongo
  $ db.walk.aggregate([{$group:{"_id":"$dateWalk",Count:{$sum:"$distance"}}}])
  </code></pre>
  
  <p>but, I want use $sum in my program java not in console.</p>
  
  <p>So please, I need your help about the syntax similar to this with mongoDB</p>
  
  <pre><code>// this calculate the sum of all distance in walk's document
  @Query("select sum(distance) from Walk")
  public Double sumDistance();
  </code></pre>
  
  <p>thanks in advance :)</p>