This is a patch to a recent checkout of Trunk from SVN.
The reports were showing count of invoices, total amount and amount paid
all incorrectly with all search and report options at default.
With this change, the summary data is generated by encapsulation the
query used for the detail report in an outer select that summarizes it,
and the report no longer produces the errors it did.