Change order of havings and orderby clauses on select.