Decode of SQL

Source: Internet
Author: User

SELECT * from A ORDER by DECODE (Aa, NULL,Ab) ;

Aa Ab

--------    ----------

1 19

< Strong> < Strong> < Strong> null        2

3 1

4 10

with decode When a function's statement is sorted, it is found that the AA field in a row is null when it is given a Span style= "Font-size:medium" > the AA field, therefore Span style= "font-size:14px" > aa field participates in sorting by this value.

In the Redshift database:

1.select carr_cd, DECODE (CARR_CD, ' JL ', ' Jo ', CARR_CD) from the Order by DECODE (CARR_CD, ' JL ', ' Jo ', carr_cd), CARR_CD; Wrong ambiguous

2.select carr_cd, DECODE (carr_cd, ' JL ', ' JO ', CARR_CD) from A order by CARR_CD; Wrong ambiguous

3.select DECODE (CARR_CD, ' JL ', ' Jo ', carr_cd) from A Order by DECODE (CARR_CD, ' JL ', ' Jo ', CARR_CD); Right

4.select CARR_CD from A order by DECODE (CARR_CD, ' JL ', ' JO ', carr_cd), CARR_CD; Right

Decode of SQL

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.