Queries now have raw text and are transformed later

* Also fixed is-aggregation to check for AS in SELECT
Add sorting to aggregations