You can have a look at Jasper Reports:
http://www.docstoc.com/docs/2139263/Jasper-Report-Tutorial
or
http://www.javaworld.com/javaworld/jw-09-2002/jw-0920-opensourceprofile.html
It's a smart framework to generate reports.
You can have a look at Jasper Reports:
http://www.docstoc.com/docs/2139263/Jasper-Report-Tutorial
or
http://www.javaworld.com/javaworld/jw-09-2002/jw-0920-opensourceprofile.html
It's a smart framework to generate reports.
You didn't give any details about the database back end you will be using, but in general the most efficient way to generate this information will be to process the data aggregation and filtering on the database side with the correct SQL and pass only the result set to your report generator. For the first example, which appears to be an aggregation of all of the data in the table, the database engine will have to sort and process all of the rows, but you'll be better off doing it there instead of the client. For queries involving subsets of the data, make sure you're indexed correctly for your queries.