Fixed exception from invalid cast

Scalar was a long integer.
Added support for column aliases

i.e.: COUNT(*) AS `count`
Added formatting for column aliases