Effect of null values on Sorting in oracle

Source: Internet
Author: User

Effect of null values on Sorting in oracle solution: Method 1: Use nvl function Syntax: Nvl (expr1, expr2) If EXPR1 is NULL, EXPR2 is returned, otherwise, EXPR1. select name, NVL (TO_CHAR (COMM), 'not application') FROM TABLE1 are returned. Once you understand the NVL syntax, you can use it in sorting, for example: order by nvl (FIELD, '0') Method 2: Use other functions, such as decode and case. Method 3: nulls first or nulls last Syntax: Nulls first: records that indicate null values will be ranked first Nulls last: indicates that the record with the null value is placed at the end -- the null value is always placed at the beginning of select * from table order by FIELD asc nulls first -- the null value is always placed at the end of select * from table order by FIELD asc nulls first is compared with the above method, the third method is more convenient.

Related Article

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.