issue 11 fixed - distinct clause properly wrapped if row numbers are added