SQL:条件函数
1、 IF(条件表达式, a, b):条件判断为True时,返回a,为False则返回b
select if(a>b,a,b) cc
2、COALESCE(col1, col2, col3...) :返回第一个不为null的值
select coalesce(col1,col2,col3...) from data_table
3、NVL(a, b):当a不为null,则返回a,否则返回b
select nvl(a,b) from data_table
4、NULLIF(a, b):与NVL基本一致
5、case when的两种形式:多条件判断
形式1:
select case a when b then c when d then e ... else f end col_name from data_table 形式2: select case when a then b when c then d ... else f end col_name from data_table
6、ISNULL( a ) :判断a是否为null
7、ISNOTNULL ( a ):判断a是否不为null
浙公网安备 33010602011771号