Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用GreenDao中的GROUPBY_Android_Sqlite_Greendao_Greendao Generator - Fatal编程技术网

Android 如何使用GreenDao中的GROUPBY

Android 如何使用GreenDao中的GROUPBY,android,sqlite,greendao,greendao-generator,Android,Sqlite,Greendao,Greendao Generator,我在SO中发现了一些与这个问题相关的问题,但对我帮助不大。我想在Android中使用GreenDao库构建一个查询,查询应该按照datetime的降序抓取包含特定电话号码的所有行,并且我还想按组名对它们进行分组。 我的问题是: List<activity> activities = activityDao.queryBuilder().where(Properties.Contact_number.eq(phonenumber)).orderDesc(Properties.Da

我在SO中发现了一些与这个问题相关的问题,但对我帮助不大。我想在Android中使用GreenDao库构建一个查询,查询应该按照datetime的降序抓取包含特定电话号码的所有行,并且我还想按组名对它们进行分组。 我的问题是:

   List<activity> activities = activityDao.queryBuilder().where(Properties.Contact_number.eq(phonenumber)).orderDesc(Properties.Date_time).build().list();
List activities=activityDao.queryBuilder().where(Properties.Contact_number.eq(phonenumber)).orderDesc(Properties.Date_time).build().List();
如何在上述查询中包括GROUP BY,以便按
GROUP\u name
对行进行分组(我在表中有GROUP\u name作为列)


我在GreenDao中没有找到任何GROUP BY方法,不确定我是否正确。

GROUP BY
不受GreenDao支持。
您可以使用以下技巧:

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

它允许您使用字符串构建where子句。

谢谢。但是,我还想将它们按日期时间降序排列。更新答案。在这里,您只需“手动”构建where子句,然后就可以按如下操作before@Naroju它对你有用吗?我正在用这个,但它一直在崩溃