“按NULL排序"是什么意思? [英] what does this mean "order by NULL"

查看:24
本文介绍了“按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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆