3

I have found few questions related to this issue in SO, but did not help me much.I want to construct a query in Android using GreenDao library, query should grab all the rows containing particular phonenumber in descending order of datetime and I also want to group them by group name. My query:

   List<activity> activities = activityDao.queryBuilder().where(Properties.Contact_number.eq(phonenumber)).orderDesc(Properties.Date_time).build().list();

How to include GROUP BY in above query so as to group the rows by group_name(I have group_name as column in table)?

I did not find any GROUP BY method in GreenDao,not sure if I am correct.

Naroju
  • 2,637
  • 4
  • 25
  • 44

1 Answers1

3

GROUP BY is not supported by GreenDao.
You can use this trick :

where(new WhereCondition.StringCondition(Properties.Contact_number.eq(phonenumber) + "GROUP BY group_name")).orderDesc(Properties.Date_time).build().list();

It let you build your where clause using String.

HelloSadness
  • 945
  • 7
  • 17