简体   繁体   中英

Using SUM in Jasper Reports Variables

I have a SQL query (resolved in a previous question) that returns aa table:

+--------+--------+------+----------+
| ID     | Gender | Ward | Duration |
+--------+--------+------+----------+
|  43845 | Female | WD   |    26582 |
|  10519 | Female | WD   |   302777 |
|  16728 | Female | WD   |   244230 |
|  25113 | Male   | WD   |     7812 |
|  28445 | Female | WD   |  3020399 |
|  60649 | Female | WD   |    12970 |
|  81445 | Female | WD   |    13040 |
| 389760 | Female | WD   |     7757 |
|  22698 | Male   | WD   |     2399 |
| 341070 | Female | WD   |     7575 |
+--------+--------+------+----------+

I then have the following segments in JasperReports:

<variable name="WardTimeTotal" class="java.lang.String" calculation="Sum">
<variableExpression><![CDATA[$F{Duration}]]></variableExpression>
</variable>

<textField evaluationTime="Report">
<reportElement uuid="2239f376-ee94-43ce-8a33-735d9a77569e" x="226" y="90" width="292" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$V{WardTimeTotal}]]></textFieldExpression>
</textField>

The actual data set has many 1000's of records and what is puzzling me is that the total duration does not seem to reflect the reality. For example on one run of 70,000 records the result was 127 seconds (ultimately I need to report hours). It occurred to me that there may be an issue with Integer size, but I am not sure how to address that.

Just wondering what I have missed here?

好的-愚蠢的错误-java.lang.String应该是java.lang.Long很麻烦!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM