Reputation: 215
Is there a way to add ROW_NUMBER()
simply based on the default row order without using OVER (ORDER BY ...)
?
Upvotes: 2
Views: 3548
Reputation: 15893
For PostgreSQL and MYSQL 8.0
row_number()over()
For SQL Server and oracle it will be:
row_number()over(order by (select null))
But this without mentioning proper order by clause it's not guaranteed to have same row number for a column everytime.
Upvotes: 1
Reputation: 32609
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
.
Upvotes: 2