How to query multiply 2 cell for each row using Realm? -


i have 1 table has 2 fields quantity , price , want multiply both fields value: here want possible using mysql

quantity| price | total  6       |   2  |  null // should 12 2       |  10   |  null // should 20 

above can done using

select      quantity, price,      quantity* price 'total'  mytable 

i want same result using realm query .. how can achieve ..any appriciated .. thank you.

using realm android, you'd need add new field, , custom setters.

this solution supported 0.88.0+

public class extends realmobject {     private long quantity;     private long price;     private long total;      public long getquantity() {         return quantity;     }      public long getprice() {         return price;     }      public long gettotal() {         return total;     }      public void setquantity(long quantity) {         this.quantity = quantity;         this.total = this.quantity * price;     }      public void setprice(long price) {         this.price = price;         this.total = this.quantity * this.price;     }      public void settotal(long total) { // preferably don't use         this.total = total;     } } 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -