GROUP BY查询使用sqlite.query()函数 [英] GROUP BY query using sqlite.query() function

查看:236
本文介绍了GROUP BY查询使用sqlite.query()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有sqlite的工作和测试查询。

I have sqlite working and tested query.

我只是想将其转换成 sqlitedatabase.query(); 功能

i just want to convert it into sqlitedatabase.query(); function

select distinct id, date ,sum(goal) from goal where id=0 and date = 'Sep 15, 2015' group by id, date;

如何实现这一目标?

How to achieve this ?

推荐答案

尝试以下。

String table = goal;
String[] columns = new String[] { "distinct id", "date", "sum(goal)" };
String selection = "id=? and date=?";
String[] arguments = new String[] { "0", "Sep 15, 2015" };
String groupBy = "id, date";
String having = null;
String orderBy = null;
db.query(table, columns, selection, arguments, groupBy, having, orderBy);

见<一href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#query(java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String)"相对=nofollow> DOC

这篇关于GROUP BY查询使用sqlite.query()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆