Set type when inlining aggregation functions.

Fixes issue #862. Test in CountTest.qOuterJoinLength.

Review by @cvogt