0

I have a list of records. All records have names, quantities and project names. Records can be duplicate in the list. I wanted to group the records by project name, so I used report group, but I also wanted to sum the same records within a project if there are duplicate ones.

Excel sheet now:

project name: 123 (in Group header)

Name Quantity (in Group header)

item1 15 (in Detail band)

item2 5 (in Detail band)

item2 7 (in Detail band)

item3 11 (in Detail band)

Excel sheet I prefer:

project name: 123 (in Group header)

Name Quantity (in Group header)

item1 15 (in Detail band)

item2 12 (in Detail band 5+7)

item3 11 (in Detail band)

I use sql query. I tried to sum up the records in sql, but then I could not group the records by project name, since all records were summed without grouping by project name.

I found this: Grouping records in JasperReports

But this topic deals only with grouping and not summing within group

I hope someone can show how to set ireport.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Zeghra
  • 447
  • 5
  • 14

1 Answers1

0

I've been suffering to find answer for a week and now that I'd posted my question here, I found a solution shortly that.

In sql query "Select item.item_name, project.project_name, sum(inventory.item_quantity) ... From project, item, inventory ... Where (project.projectid = inventory.projectid) and (item.itemid = inventory.itemid) ... Group By project.project_name, item.item_name..."

Adding report group in ireport: (in Report Inspector view) right click on report and select Add Report Group > Select group by: project.project_name > next: add group header and footer.

I use Netbeans 8.2 and IReport 5.5

Zeghra
  • 447
  • 5
  • 14