Intermediate DataSet use sql to query. http://smartloli.org
If you want to sum up a set of data, go to the maximum, minimum, grouping, etc., need to customize the algorithm to complete these functions. Such as :
[{"id":1,"name":"aaa","age":20},{"id":2,"name":"bbb","age":21},{"id":2,"name":"ccc","age":22},{}...]
// ... Sum
long sum = 0L
for(int i=0;i<array.size();i++){
JSONObject object = (JSONObject)array.get(i);
sum += object.getLong("age");
}
// ...
// ... Use SQL
SELECT SUM(column) FROM TBL;
// ...
In pom.xml
,you can add follow context :
<dependency>
<groupId>org.smartloli</groupId>
<artifactId>jsql-client</artifactId>
<version>1.0.0</version>
</dependency>
you can import JSqlUtils
class, and use query
method,like this :
JSqlUtils.query(tabSchema, tableName, dataSets, sql);