简体   繁体   English

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

[英]multiple queries in iReport's Report Query Dialog Box

I want to make following kind of report using ireport: 我想使用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: iReport的“报表查询”对话框中,我可以进行查询:

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? 因此,我想问一下如何使用“报告”对话框中的ireport对单个jrxml文件进行多个查询?

Thanks... 谢谢...

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. 然后在报告中创建3个变量以计算3个所需值。

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. 保持当前查询不变,并添加一个变量,该变量将损坏和未损坏的项目相加以获得总计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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