title: Is possible to sum a relationship field? [Using Realm]
body: <p>I am trying to find a away to SUM the relationship field, but always throw an exception~ </p>
  
  <p>So it`s possible to sum a relationship filed by using realm database?</p>
  
  <p>if u knows where i write wrong, please tell me, thanks a lot :)</p>
  
  <p>Assuming I have the following dataset:</p>
  
  <pre><code>public class Service extends RealmObject {
      private String id;
      private RealmList&lt;Service&gt; extras;
      private boolean selected;
      // getters and setters
  }
  
  public class ServiceExtra extends RealmObject {
      private String id;
      private float price;
      private boolean selected;
      // getters and setters
  }
  </code></pre>
  
  <p>and then, i guess the query code like this</p>
  
  <pre><code>Realm.getDefaultInstance()
       .where(Service.class)
       .equalTo("selected",true)
       .equalTo("extras.selected",true)
       .sum("extras.price");
  </code></pre>
  
  <p>but always throw</p>
  
  <pre><code>java.lang.IllegalArgumentException: Field does not exist: extras.price
       at io.realm.RealmObjectSchema.getAndCheckFieldIndex(RealmObjectSchema.java:756)
       at io.realm.RealmQuery.sum(RealmQuery.java:1592)
  </code></pre>
  
  <p>UPDATE</p>
  
  <pre><code>Realm realm = Realm.getDefaultInstance();
  Service service = realm.where(Service.class).equalTo("selected",true).findFirst();
  int totalPrice = service.extras.where().equalTo("selected",true).sum("price");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Realm realm = Realm.getDefaultInstance();
  RealmResult&lt;Service&gt; services = realm.where(Service.class)
              .equalTo("selected",true).finAll();
  int totalPrice;
  for(Service service : services){
      totalPrice += service.extras.where()
              .equalTo("selected",true).sum("price");
  }
  </code></pre>