Android - 如何在 Sqlite 中根据重复数据合并行

Android - How to combine rows based on duplicate data in Sqlite

嗨,我的数据库中有这样的东西 -

现在我需要编写一个查询来得到以下结果 -

任何帮助将不胜感激。

试试这样的东西:

select month, day_of_week, sum(data), count(_id)
from table
group by month, day_of_week

您可以在 Android SQLite

中使用正常的 SQL 语句
SELECT month, day_of_week, sum(data) AS total_data, count(month)AS number_of_rows_combined 
FROM --table--
GROUP BY month, day_of_week

在 Android 中,您可以将 SQL 用作:

Cursor c1 = db.rawQuery(
    "SELECT month, day_of_week, sum(data) AS total_data, count(_id)AS number_of_rowa_combined 
FROM --your table--
GROUP BY month, day_of_week",
    new String[] {}
);