在每个分组后增加一行数据

【问题】

I have a query in a stored procedure like below

select x,y from table

and the results will look like below

x y

1 a

1 b

2 a

2 b

3 a

3 b

i need to add a blank column or zeros when the value of x changes like below

x y

1 a

1 b

0 0

2 a

2 b

0 0

3 a

3 b

Can this be done by sql or since i’m using the data for birt reports can this be done with birt?

sounds like you’re looking for the wrong solution to your problem. most reporting tools should be able to handle groups of data without having to manipulate the source data in this way. you need to use a group header row or something similar.– TannerJun 9 at 10:45

Thanks, somehow i didn’t think of using group header as a blank row– Charles

【回答】

想在结果集中插入数据,但不能用报表的 group 方案,这种情况用 SQL 处理比较麻烦。可以用集算器来准备数据,代码简单易懂:



A

1

=orac.proc("{call yoursp(?)}",:101:"o":table1)

2

=table1.create().record([0,0])

3

=table1.group@o(x).conj(~|A2)

A3 结果如下:

1png

BIRT 可通过 JDBC 访问集算器,可以像数据库一样使用,参考Java 如何调用 SPL 脚本