【问题标题】:How to read some rows of database, sum on some columns and store in collection?如何读取数据库的某些行,对某些列求和并存储在集合中?
【发布时间】:2019-08-01 17:24:18
【问题描述】:

我有一个 Access 文件,其中包含三张表(每张表属于一个客户),每张表包含 25 周内 9 种产品的订单。

我想将 3 种产品的总和存储在一个集合中 12 周。

例如:

order list of customer

如何对数据库进行一些操作(如对列求和)并将它们存储在集合中?

【问题讨论】:

    标签: database collections anylogic


    【解决方案1】:

    类似的东西。

    List <Integer> result=selectFrom(customer1).list(customer1.product1);
    double theSum=sum(result,c->c.intValue());
    

    另一种选择:

    int theSum=(int) selectFirstValue(int.class,"SELECT SUM (product1) FROM customer1;");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-31
      • 2016-04-07
      • 1970-01-01
      • 2019-11-10
      • 1970-01-01
      • 2016-08-28
      • 1970-01-01
      相关资源
      最近更新 更多