“按NULL排序"是什么意思? [英] what does this mean "order by NULL"
问题描述
我用的是oracle 11g,下面的行顺序为空是什么意思
选择 f_value,row_number() over (order by null) 作为 id从表名"
ROW_NUMBER()
的 OVER()
子句需要 ORDER BY
>
使用ORDER BY NULL
是一种解决方法,它满足语法要求但实际上并没有改变数据的顺序.实际上,这是一条完全不订购的指令.
注意:有些人(包括我自己)更喜欢使用 SELECT 1
而不是 SELECT NULL
但效果上没有区别.>
底线:不是很好,但很管用.
<小时>提示:TSQL 不允许直接使用 SELECT 1,但您可以使用 (SELECT 1)
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"
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)
这篇关于“按NULL排序"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!