Rewriting calc queries to use subqueries

This fixes calcs on subform fields in many cases, however grouping is
broken because the group by clause is not being built the same, and/or
the handles it references need to be exposed in the outer query now.
Fixed grouping, changed whitespace :-(
Merge pull request #52 from jegelstaff/Fixing-calculations-on-subform-fields

Rewriting calc queries to use subqueries