iReport的报表查询对话框中的多个查询

发布于 2025-01-01 17:49:27 字数 847 浏览 0 评论 0原文

我想使用 ireport 制作以下类型的报告:

Total Items: TOTAL_NO_OF_ITEMS
Damaged Items: NO_OF_DAMAGED_ITEMS              
Non Damaged Items: NO_OF_NON_DAMAGED_ITEMS

表结构是:

Items{
item id int PK,
item_status varchar  <!--having values as 'damaged' or 'non-damaged')-->
}

iReport 的报告查询对话框中,我可以给出查询:

select count(*) item_counts , item_status status  from Items group by item_status;

这将为

Damaged Items: NO_OF_DAMAGED_ITEMS              
Non Damaged Items: NO_OF_NON_DAMAGED_ITEMS

报告中的行生成 BUT:

Total Items: TOTAL_NO_OF_ITEMS

我必须再运行一个查询:

select count(*) total_items from items

所以我想问一下如何在报告对话框中使用 ireport 对单个 jrxml 文件进行多个查询?

谢谢...

I want to make following kind of report using ireport:

Total Items: TOTAL_NO_OF_ITEMS
Damaged Items: NO_OF_DAMAGED_ITEMS              
Non Damaged Items: NO_OF_NON_DAMAGED_ITEMS

Table structure is:

Items{
item id int PK,
item_status varchar  <!--having values as 'damaged' or 'non-damaged')-->
}

In iReport's Report Query Dialog box I can give query:

select count(*) item_counts , item_status status  from Items group by item_status;

that will generate

Damaged Items: NO_OF_DAMAGED_ITEMS              
Non Damaged Items: NO_OF_NON_DAMAGED_ITEMS

BUT for the line in report:

Total Items: TOTAL_NO_OF_ITEMS

i have to run one more query :

select count(*) total_items from items

So i want to ask how to can i give more than one queries for a single jrxml file using ireport in Report Dialog Box?

Thanks...

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

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

发布评论

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

评论(1

隔岸观火 2025-01-08 17:49:27

对于此类问题不需要多次查询。如果需要,您可以在数据库中进行所有处理:

select count(*) as item_counts, item_status as status from Items group by item_status
union all
select count(*) as item_counts, 'all items' as status from Items

或者您可以在数据库中不进行任何处理:

select * from Items
order by item_status

然后在报告中创建 3 个变量来计算您的 3 个所需值。

当然,您也可以使用混合动力。保持当前查询不变,并添加一个变量来汇总损坏和未损坏的项目以获得总数。

There's no need for multiple queries for this type of problem. You could do all of the processing in the database if you want:

select count(*) as item_counts, item_status as status from Items group by item_status
union all
select count(*) as item_counts, 'all items' as status from Items

Or you could do no processing in the database:

select * from Items
order by item_status

Then in the report create 3 variables to calculate your 3 desired values.

And of course you could use a hybrid. Keep your current query unmodified, and add a variable that sums up the damaged and undamaged items to get the total.

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