标签:select font car redshift span bsp code 排序 就会
select * from A ORDER BY DECODE(Aa, NULL,Ab);
Aa Ab
-------- ----------
1 19
null 2
3 1
4 10
带有decode函数的语句排序时发现某行的里Aa字段为null时就会用该行的Ab字段的值赋予Aa字段,故而Aa字段以此值来参加排序。
在redshift数据库里:
1.select carr_cd , DECODE(carr_cd , ‘JL‘ , ‘JO‘ , carr_cd) from A order by DECODE(carr_cd,‘JL‘,‘JO‘,carr_cd) , carr_cd ; 错 ambiguous
2.select carr_cd , DECODE(carr_cd , ‘JL‘ , ‘JO‘ , carr_cd) from A order by carr_cd ; 错 ambiguous
3.select DECODE(carr_cd , ‘JL‘ , ‘JO‘ , carr_cd) from A order by DECODE(carr_cd,‘JL‘,‘JO‘,carr_cd) ; 对
4.select carr_cd from A order by DECODE(carr_cd,‘JL‘,‘JO‘,carr_cd) , carr_cd ; 对
标签:select font car redshift span bsp code 排序 就会
原文地址:http://www.cnblogs.com/huche123/p/7257532.html