Skip to content
Advertisement

Is there a way to add ROW_NUMBER() without using OVER (ORDER BY …) in SQL

Is there a way to add ROW_NUMBER() simply based on the default row order without using OVER (ORDER BY ...)?

Advertisement

Answer

There is no implicit ordering to rows in a table, it is a logical unordered set.

however you can do row_number() over (order by (select null))

As suggested by Itzik Ben-Gan from his book on window functions.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement