what does this mean “order by NULL”

余生颓废 提交于 2019-12-04 04:02:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!