I found a workaround which was to use my query to insert into a temp table and then select from the temp table, which completed correctly.