java - 从 Parse.com localDatastore 计算列(数字类型)的总和时遇到问题?

标签 java android database arraylist parse-platform

My table , and the column i need the total value of in red

嗨, 有人可以帮我进行 parse.com 查询和计算吗? 我想从我的 localDatastore 计算 parse.com 中的列总和 (DEBT),如果第一个选项不可行,则从 Web 计算。 我尝试将元素存储在数组列表中,但没有成功。 那么我该怎么做呢?

提前致谢;)

最佳答案

Parse 不支持 SUM 查询。这是official statement .

无论如何,您需要使用云代码或获取所有行来实现您想要的(遗憾的是)客户端。

编辑

在客户端,发出 ParseQuery.findInBackground() 请求并遍历所有项目,添加值以使 SUM 成为客户端。

new ParseQuery<Whatever>("WHATEVER")
    .findInBackground(new FindCallback<Whatever>() {
        @Override
        public void done(List<Whatever> list, ParseException e) {
            // check for ParseException
            Integer sum = 0;
            for (final Whatever whatever : list) {
                sum += (Integer) whatever.get("Debt");
            }
            // there is your SUM
        }
});

关于java - 从 Parse.com localDatastore 计算列(数字类型)的总和时遇到问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30096427/

相关文章:

java - Libgdx 为什么我的按钮在鼠标点击时没有响应

android - 使用 ACTION_CAPTIVE_PORTAL_SIGN_IN

Android gradle库项目: package extra modules and jars

java - RadioGroup 中 RadioButton 的 SharedPreferences.

java - 从数据库检索值并将其返回给调用方法

java - 如何异步接收来自Web的数据并在下一行代码中使用结果字符串?

java - 一段时间后继续工作吗?

java - SpringMVC、null spring beans、servlet 和 Apache Thrift

database - 将数据库结果存储在本地存储中以增加加载时间?

php - CodeIgniter 中的手动事务