how we can use group by and having in android?
i want to use this query :
select sum(Quantity) from tbl1 group by name having id=lastid
and get result to use in other place of my project
i saw in one page for groupy by use this code:
return mDd.query(DATABASE_TABLE,new String[] {
KEY_ROWID,
KEY_TITLE,
KEY_DATAS,
KEY_BODY,
KEY_DATE_TIME
},null,null,KEY_TITLE,null,null);
but i don t know what should i do for having and sum()!!
You should use the
rawQuerymethod of the SQliteDatabase class :Inspired from Fetching a SQLite SUM in Java on Android