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