栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

分组后合并成员

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

分组后合并成员

【问题】

I am new to jasper. I am having a problem to design a report which does the same like group_concat() function in my sql..  i am using a sql server so cannot use that function in my query.

My input is something like this.

Col1   Col2    Col3     Col4
10       1234    Sam     A12G3
10       1234    Sam     K78DE
10       1234    Sam     MAT12
20      1456    Tom     E12F4
20      1456    Tom     KAR3R
20      3217    Tom      G45G4

my output should be like 

Col1   Col2    Col3     Col4
10       1234    Sam     A12G3 , K78DE , MAT12  
20      1456    Tom     E12F4 , KAR3R
20      3217    Tom      G45G4

I am trying to create a variable using the below expression.

Class : java.lang.String ,  CALCULATION: Nothing , Incrementype: Group , Incrementgroup: Col2

expression is  $F{Col4} + "," + $F{Col4}

this one is not working.. Could you please help me on this please

【回答】

SQL 和 Jasper 应该都能实现 group_concat 函数,只是代码比较难写。可以试试用 SPL 来辅助 Jasper。

如下代码就能实现与 group_concat 等价的功能,而且与数据库无关:

A
1=mySqlDB.query("select * from   table1"). group(Col1,Col2,Col3;~.(Col4).concat@c():Col4)

集算器提供 JDBC 接口与 Jasper 集成,与数据库的用法相同,详情参考【JasperReport 调用 SPL 脚本】

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/733128.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号