Fix for row number window function optimization

Yes that is right. Since we cannot know which rows they are, we get all the rows and check that the number of rows returned by the row_number query is 10 less than all the rows, and that the selected rows are a subset of all the rows. 

Same goes for the test case below.