Introduction to Oracle nls_sort and nlssort sorting functions

Source: Internet
Author: User

Introduction to Oracle nls_sort and nlssort sorting functions (1) Before alter session set NLS_SORT = '', sorting affects the entire SESSION Oracle9i, Chinese is sorted by binary encoding. The sorting by pinyin, radical, and stroke function is added to oracle9i. Set the NLS_SORT value SCHINESE_RADICAL_M to sort SCHINESE_STROKE_M By the beginning (First Order), strokes (Second Order), and heads (Second Order) SORT SCHINESE_PINYIN_M sort by pinyin oracle9i adds the sort by pinyin, radical, and strokes function SELECT * from team order by nlssort (TEAM name, 'nls _ SORT = SCHINESE_PINYIN_M ') stroke SELECT * from team order by nlssort (TEAM name, 'nls _ SORT = SCHINESE_STROKE_M ') Radical SELECT * from team order by nlssort (TEAM name, 'nls _ SORT = SCHINESE_RADICAL_M ') (2) Another example is to query the road list in the View: sSql = string. forma T ("select distinct ({0}) from {1} order by nlssort ({0}, 'nls _ SORT = SCHINESE_PINYIN_M ')", sFieldDL, sViewDL); (3) another example of the data in a table is like this: PROJECTNO --------------------- Qin city PC2010-5 Qin city PC2011-6 Qin city PC2011-40 Qin South PC2011-5 Qin city GC2011-5 (there are many) the first 2 words of data is the city name, the file name "-" is followed by the number of files. I want to know how to sort them in ascending order using SQL statements. The city names must be sorted first, the city name is the same as the name of the file after the sorting in ascending order, and the file name is the same as the name of the file after the sorting. Note: Using select projectno from dual order by projectno asc alone cannot be implemented. Select projectno from dual order by substring (projectno, 1, 2) asc, substring (projectno, 3, 6) asc, substring (projectno, 9, 2) asc can be used

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.