When order by is null in Oracle

Source: Internet
Author: User

Http://easyui.btboys.com/oracle-sort-on-null-value-processing.html

 

The default null value sorted by order by in Oracle is the largest, which is placed before all data.
 
However, in most cases, we want the null value to sink to the end. In this case, Oracle provides an extended sort Syntax: nulls first or nulls last
 
Nulls first and nulls last are syntaxes supported by Oracle order.
If the expression nulls first is specified in order by, the null value of the record is ranked first (whether ASC or DESC)

If the expression nulls last is specified in order by, the records with null values will be placed at the end (whether ASC or DESC)
The syntax is as follows:
-- Always put nulls at the beginning

Select * from Dual order by name nulls first

-- Always put nulls at the end

Select * from Dual order by name DESC nulls last

 

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.