下面的方法需要ORACLE9i和以上的版本才支持。 Oracle9i之前,中文是按照二进制编码进行排序的。 在oracle9i中新增了按照拼音、部首、笔画排序功能。设置NLS_SORT值 SCHINESE_RADICAL_M 按照部首(第一顺序)、笔划(第二顺序)排序 SCHINESE_STROKE_M 按照笔
下面的方法需要ORACLE9i和以上的版本才支持。<span><font face="新宋体">1: </font></span><span><font face="新宋体"><span>//按照笔划排序<br><span>2: </span></span><span>select </span><span>* </span><span>from dept order by nlssort</span><span>(</span><span>name</span><span>,</span><span>'NLS_SORT=SCHINESE_STROKE_M'</span></font><span><font face="新宋体">);<br><span>3: </span></font></span><font face="新宋体"><span>//按照部首排序<br><span>4: </span></span><span>select </span><span>* </span><span>from dept order by nlssort</span><span>(</span><span>name</span><span>,</span><span>'NLS_SORT=SCHINESE_RADICAL_M'</span></font><span><font face="新宋体">);<br><span>5: </span></font></span><font face="新宋体"><span>//<strong>按照拼音排序</strong>,此为系统的默认排序方式<br><span>6: </span></span><span>select </span><span>* </span><span>from dept order by nlssort</span><span>(</span><span>name</span><span>,</span><span>'NLS_SORT=SCHINESE_PINYIN_M'</span><span>);</span> </font></span>
注意,该SQL指令并非标准指令,在SQLServer下面的实现方式并不相同。
把查询出来的人员姓名按照拼音的第一个字母进行排序
select * from ryjbqk where (xm like '%??%' or xm like '%′T%' or xm like '%o?%') and ryid not in(select ryid from rc_zsdj where czt='1') order by nlssort(xm,'NLS_SORT=SCHINESE_PINYIN_M')