如何通过将一个查询的输出作为另一个查询的输入来创建 jasper 报告

发布于 2024-12-24 23:37:53 字数 1206 浏览 1 评论 0原文

我尝试使用数据集。但是如何将一个数据集查询输出作为另一个数据集的输入。

例如,资产负债表类型报表视图。

我的第一个查询是

SELECT column_name_one FROM table WHERE C_GL_PRIMARY='LIABILITY'

假设此查询返回 2 行,例如 DEPOSIT、LOAN。 我的第二个查询是

SELECT colum_name_second FROM table WHERE C_GL_ONE='column_name_one'

(我使用数据网格完成并且正在工作)

例如

DEPOSIT
       term deposit
       pigmy deposit
LOANS
       term loan
        pigmy loan

直到这里一切都很好,但现在我还有一个查询需要第二个查询的输出作为该查询的输入。

select column_name_third from table where C_GL_TWO='colum_name_second'

在这里,我无法将“colum_name_second”作为输入,因为该字段位于列表下,而不是详细信息。

我的报告应该如下所示


DEPOSIT
       term deposit
                 new term deposit
                 old term deposit
       pigmy deposit
                 ww pigmy deposit
                 bbb deposit
LOANS
       term loan
                new tem loan
                current term loan
        pigmy loan
                pigmyloannew

有人可以帮助我吗...有什么办法可以做到这一点。

谢谢。

I tried using dataset. But how can I give one dataset queries output as input to another dataset.

For example, balancesheet type report view.

My first query is

SELECT column_name_one FROM table WHERE C_GL_PRIMARY='LIABILITY'

Suppose this query returns me 2 rows, like DEPOSIT,LOAN.
My second query is

SELECT colum_name_second FROM table WHERE C_GL_ONE='column_name_one'

(i did it using datagrid and is working)

for example

DEPOSIT
       term deposit
       pigmy deposit
LOANS
       term loan
        pigmy loan

Till here everything is fine but now i have one more query which need output of second query as input for this query.

select column_name_third from table where C_GL_TWO='colum_name_second'

Here i am not able to put "colum_name_second" as input becoz it this fiels is under list not in details..

My report should look like this


DEPOSIT
       term deposit
                 new term deposit
                 old term deposit
       pigmy deposit
                 ww pigmy deposit
                 bbb deposit
LOANS
       term loan
                new tem loan
                current term loan
        pigmy loan
                pigmyloannew

Can anybody help me ...Is there any way to do it.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天气好吗我好吗 2024-12-31 23:37:53

1ST-在主报告查询中创建参数,并在 HashMap 中输入参数值以填充它。
2nd-在数据集中创建参数并在数据集查询中使用该参数。$p{Dataset_parameter}
3rd-如果您使用列表组件,右键单击然后转到编辑列表数据源,然后单击参数,然后添加数据集参数并使用主查询输出属性对其进行配置。

Ex-select ID,NAME from CALENDAR WHERE REGION=$P{REGION_ID}--REGION_ID main report parameter
   SELECT HOLIDAY_NAME,DATE_PICKER FROM HOLIDAYS WHERE CAL_ID=$P{CAL_ID} --CAL_ID dataset  
parameter.configure as per instruction above with $P{CAL_ID} with expression $F{ID} 

1ST-Create the Parameter in Main report query and enter the parameter value in HashMap to populate it.
2nd-Create the parameter in dataset and use the parameter in dataset query.$p{Dataset_parameter}
3rd-If you are using List component right click on then go Edit list data source then click parameter then add the parameter of dataset and configure it with Main query output attribute.

Ex-select ID,NAME from CALENDAR WHERE REGION=$P{REGION_ID}--REGION_ID main report parameter
   SELECT HOLIDAY_NAME,DATE_PICKER FROM HOLIDAYS WHERE CAL_ID=$P{CAL_ID} --CAL_ID dataset  
parameter.configure as per instruction above with $P{CAL_ID} with expression $F{ID} 
影子是时光的心 2024-12-31 23:37:53

根据您的描述,这应该只是一个查询:

SELECT t1.column_name_one, t2.column_name_two, t3.column_name_three 
FROM table1 t1
INNER JOIN table2 t2 on (t2.C_GL_ONE = t1.column_name_one)
INNER JOIN table3 t3 on (t3.C_GL_TWO = t2.column_name_two)
WHERE t1.C_GL_PRIMARY='LIABILITY'

然后报告将被分组以完全按照您所需的报告输出显示数据。

From your description this should just be a single query:

SELECT t1.column_name_one, t2.column_name_two, t3.column_name_three 
FROM table1 t1
INNER JOIN table2 t2 on (t2.C_GL_ONE = t1.column_name_one)
INNER JOIN table3 t3 on (t3.C_GL_TWO = t2.column_name_two)
WHERE t1.C_GL_PRIMARY='LIABILITY'

Then the report would be grouped to show the data exactly as in your desired report output.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文