Fix an issue when using row_number() and limit() together