jeudi 7 juillet 2016

Calculate the sum of integer column - Greendao android

I use Greendao library in my android project, and it works very fine

this is my table:

create table Orders
(
  id int,
  dt date,
  bill int
);

now i am trying to get the sum of whole column after i excute a query on it,

like (select today's orders) then (calculate the sum of their bills)

the sum of column in sqlite was calculated using this:

select sum(bill) from Orders

I got the query working in the example below

SqlFiddle.com example

the final query looks like this:

select id, dt, bill, (select sum(bill) from Orders) total
from Orders
where id >= 3

The GreenDao generator generated code OrderDao.java and Order.java

my question is how to implement the query above in GreenDao ?

Aucun commentaire:

Enregistrer un commentaire