improved typecasting for aggregate db functions
Merge pull request #150 from herroffizier/master

Improving typecasting for aggregate db functions