ITPUB??ì3
ITPUB论坛 » Oracle开发 » order by到底以什么规则排序的?

标题: order by到底以什么规则排序的?
离线 stasnail
一般会员



精华贴数 0
个人空间 0
技术积分 320 (6069)
社区积分 0 (1258534)
注册日期 2007-1-25
论坛徽章:0
      
      

发表于 2008-6-25 17:00 
order by到底以什么规则排序的?

order by到底以什么规则排序的?
是以字段的ascii码吗?
因为我在适用cube分组时,order by的几个字段都是汉字的,那排序出来的 出来的数据很乱了.


__________________
我爱钱,但她不爱我。
只看该作者    顶部
离线 zhangweicai74
阿财


来自 贵州
精华贴数 3
个人空间 240
技术积分 5314 (241)
社区积分 20412 (65)
注册日期 2007-12-13
论坛徽章:137
2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:跆拳道
2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击

发表于 2008-6-25 17:03 
要求不明,看一下这个对你有用没有?


__________________
NEVER TOO LATE
想吃贵州家乡菜不?进来嘛,老乡!!
http://space.itpub.net/12391917/viewspace-257185
玩玩双节棍(l_l)

美丽家乡黄果树瀑布
http://space.itpub.net/12391917/viewspace-244134
只看该作者    顶部
离线 stasnail
一般会员



精华贴数 0
个人空间 0
技术积分 320 (6069)
社区积分 0 (1258534)
注册日期 2007-1-25
论坛徽章:0
      
      

发表于 2008-6-25 17:05 
我就是想问一下order by是以什么规则排序的?


__________________
我爱钱,但她不爱我。
只看该作者    顶部
离线 caizhuoyi
Oracle Stranger


精华贴数 2
个人空间 0
技术积分 1504 (1108)
社区积分 445 (1472)
注册日期 2006-3-1
论坛徽章:3
授权会员2008北京奥运纪念徽章:棒球数据库板块每日发贴之星   
      

发表于 2008-6-25 17:13 
参考:

order_by_clause

Use the ORDER BY clause to order rows returned by the statement. Without an order_by_clause, no guarantee exists that the same query executed more than once will retrieve rows in the same order.


SIBLINGS

The SIBLINGS keyword is valid only if you also specify the hierarchical_query_clause (CONNECT BY). ORDER SIBLINGS BY preserves any ordering specified in the hierarchical query clause and then applies the order_by_clause to the siblings of the hierarchy.


expr

expr orders rows based on their value for expr. The expression is based on columns in the select list or columns in the tables, views, or materialized views in the FROM clause.


position

Specify position to order rows based on their value for the expression in this position of the select list. The position value must be an integer.

You can specify multiple expressions in the order_by_clause. Oracle Database first sorts rows based on their values for the first expression. Rows with the same value for the first expression are then sorted based on their values for the second expression, and so on. the database sorts nulls following all others in ascending order and preceding all others in descending order. Please refer to "Sorting Query Results " for a discussion of ordering query results.


ASC | DESC

Specify whether the ordering sequence is ascending or descending. ASC is the default.


NULLS FIRST | NULLS LAST

Specify whether returned rows containing null values should appear first or last in the ordering sequence.

NULLS LAST is the default for ascending order, and NULLS FIRST is the default for descending order.

Restrictions on the ORDER BY Clause
The following restrictions apply to the ORDER BY clause:

If you have specified the DISTINCT operator in this statement, then this clause cannot refer to columns unless they appear in the select list.

An order_by_clause can contain no more than 255 expressions.

You cannot order by a LOB column, nested table, or varray.

If you specify a group_by_clause in the same statement, then this order_by_clause is restricted to the following expressions:

Constants

Aggregate functions

Analytic functions

The functions USER, UID, and SYSDATE

Expressions identical to those in the group_by_clause

Expressions comprising the preceding expressions that evaluate to the same value for all rows in a group.


__________________
我不在江湖,但江湖中有我的传说;
我身在江湖,江湖里却没有我的传说。
只看该作者    顶部
离线 zhangweicai74
阿财


来自 贵州
精华贴数 3
个人空间 240
技术积分 5314 (241)
社区积分 20412 (65)
注册日期 2007-12-13
论坛徽章:137
2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:跆拳道
2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击

发表于 2008-6-25 17:13 
你有没有看?

在那个帖子中老狐狸如是说:
在oracle9i中新增了按照拼音、部首、笔画排序功能。设置NLS_SORT值
SCHINESE_RADICAL_M 按照部首(第一顺序)、笔划(第二顺序)排序
SCHINESE_STROKE_M 按照笔划(第一顺序)、部首(第二顺序)排序
SCHINESE_PINYIN_M 按照拼音排序,系统的默认排序方式为拼音排序

举例如下:
表名为 dept ,其中name字段是中文,下面分别实现按照单位名称的笔划、部首和拼音排序。
1: //按照笔划排序
2: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_STROKE_M');
3: //按照部首排序
4: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_RADICAL_M');
5: //按照拼音排序,此为系统的默认排序方式
6: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M');


__________________
NEVER TOO LATE
想吃贵州家乡菜不?进来嘛,老乡!!
http://space.itpub.net/12391917/viewspace-257185
玩玩双节棍(l_l)

美丽家乡黄果树瀑布
http://space.itpub.net/12391917/viewspace-244134
只看该作者    顶部
离线 stasnail
一般会员



精华贴数 0
个人空间 0
技术积分 320 (6069)
社区积分 0 (1258534)
注册日期 2007-1-25
论坛徽章:0
      
      

发表于 2008-6-25 17:18 
哦,谢谢


__________________
我爱钱,但她不爱我。
只看该作者    顶部
离线 zhangfengh
老狐狸


精华贴数 3
个人空间 0
技术积分 12308 (95)
社区积分 5293 (272)
注册日期 2002-10-12
论坛徽章:81
现任管理团队成员2008北京奥运纪念徽章:足球2008年新春纪念徽章   
      

发表于 2008-6-25 17:24 


QUOTE:
原帖由 zhangweicai74 于 2008-6-25 17:13 发表
在那个帖子中老狐狸如是说:
在oracle9i中新增了按照拼音、部首、笔画排序功能。设置NLS_SORT值
SCHINESE_RADICAL_M 按照部首(第一顺序)、笔划(第二顺序)排序
SCHINESE_STROKE_M 按照笔划(第一顺序)、部首(第二顺序)排序
SCHINESE_PINYIN_M 按照拼音排序,系统的默认排序方式为拼音排序

举例如下:
表名为 dept ,其中name字段是中文,下面分别实现按照单位名称的笔划、部首和拼音排序。
1: //按照笔划排序
2: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_STROKE_M');
3: //按照部首排序
4: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_RADICAL_M');
5: //按照拼音排序,此为系统的默认排序方式
6: select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M');

,我不是原作的,不记得在哪里看到的,当时保留下来备查的


__________________
=======================================
接受以下奥运徽章赞助
黄色:篮球、田径、体操
红色:射击
=======================================
接受鲜花赞助
蓝色妖姬
紫蜘蛛
九尾狐狸
=======================================
狐狸在这个世界上是凭借聪明而得到生存的,并且在这个世界上占有一席之地,学习狐狸的聪明,少走弯路。
=======================================
聪明的人,能把别人的经验吸收过来,使之成为自己的经验!
=======================================
只看该作者    顶部
离线 jvkojvkoyu
小马哥2


精华贴数 0
个人空间 0
技术积分 393 (4891)
社区积分 631 (1196)
注册日期 2006-12-14
论坛徽章:122
2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船
2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船2008北京奥运纪念徽章:帆船

发表于 2008-6-25 17:58 


QUOTE:
原帖由 zhangfengh 于 2008-6-25 17:24 发表



,我不是原作的,不记得在哪里看到的,当时保留下来备查的

在老杨的个人空间里面,讲汉字拼音首字母的


只看该作者    顶部
离线 zhangweicai74
阿财


来自 贵州
精华贴数 3
个人空间 240
技术积分 5314 (241)
社区积分 20412 (65)
注册日期 2007-12-13
论坛徽章:137
2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:跆拳道2008北京奥运纪念徽章:跆拳道
2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击2008北京奥运纪念徽章:射击

发表于 2008-6-25 18:16 


QUOTE:
原帖由 zhangfengh 于 2008-6-25 17:24 发表



,我不是原作的,不记得在哪里看到的,当时保留下来备查的

拿来主义,为我所用就是我的


__________________
NEVER TOO LATE
想吃贵州家乡菜不?进来嘛,老乡!!
http://space.itpub.net/12391917/viewspace-257185
玩玩双节棍(l_l)

美丽家乡黄果树瀑布
http://space.itpub.net/12391917/viewspace-244134
只看该作者    顶部
在线/呼叫 阿日
2M-Never give up


精华贴数 0
个人空间 486
技术积分 1379 (1233)
社区积分 727 (1113)
注册日期 2004-1-4
论坛徽章:18
ITPUB元老红孩儿2008北京奥运纪念徽章:曲棍球2008北京奥运纪念徽章:棒球2008北京奥运纪念徽章:摔跤2008北京奥运纪念徽章:柔道
2008北京奥运纪念徽章:羽毛球2008北京奥运纪念徽章:举重2008北京奥运纪念徽章:垒球2008北京奥运纪念徽章:皮划艇激流回旋每日论坛发贴之星 

发表于 2008-6-25 23:00 
值得学习,我收藏了,呵呵


__________________
我欲将心向明月,奈何明月照沟渠.
阳光灿烂的日子,提高自身素质,努力向前 --自强不息 Don't give up!
相信-坚持-一定成功-多问-多看-多总结-多分析-加油
过去的都过去了,大不了从头再来,别回头,向前看!
http://blog.csdn.net/zxf_feng
只看该作者    顶部
相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问