changes to order by handling of sub query columns