Fix for row number window function optimization

Doh! I missed the check below. I just assumed you were comparing the results from both queries :)