问题
i use oracle 11g.what does the line order by null means in the following
select f_value,row_number() over (order by null) as id
from tableName"
回答1:
The OVER() clause for ROW_NUMBER() requires an ORDER BY
using ORDER BY NULL is a workaround that satifies the syntax requirement but does not actually change the order of the data. In effect it is an instruction to not order at all.
N.B.: some (myself included) prefer to use SELECT 1 instead of SELECT NULL but there is no difference in effect.
Bottom line: not great, but it works.
tip: TSQL does not permit the direct use of SELECT 1, but you may use (SELECT 1)
来源:https://stackoverflow.com/questions/25377014/what-does-this-mean-order-by-null