PIR-839 Change order of operations to do Group BY before from/where/having