Join row_number over function in dremio getting Wrong Result

Any Alternative we can use instaid of Row _function() i see similar Thred here