Processing of null values when order by is used in oracle

Source: Internet
Author: User


Processing of null values when order by is used in oracle: When oracle sorts query results, null values exist in the column to be sorted, specify the NULL value at the beginning or at the end of the www.2cto.com Keyword: Nulls First; Nulls Last default condition: null defaults to the maximum value (I .e., asc Ascending Order <small --> large>, the value of null is listed at the end; the value of desc is listed at the beginning in descending order <big --> small>. syntax supported by Oracle Order by 2. if Nulls first is specified, the null value is ranked first (whether asc or desc. if Nulls is set to last, the records with null values are placed at the end (whether asc or desc)
Syntax example: (Table: Tab_A columns with some null values Col_A) select * from Tab_A order by Tab_A. col_A (asc/desc) nulls first ------> the null value is at the beginning of select * from Tab_A order by Tab_A. col_A (asc/desc) nulls last ------> null values are placed at the end of the other method: When order by is used, Nvl, NVL2, Decode, case ..... when .... end; and other functions to process the null value of the column, for example: select * from Tab_A order by NVL (Tab_A. col_A, 'abc') (asc/desc );
 

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.