genshengxiao 2020-07-05
语法: if(boolean testCondition, T valueTrue, T valueFalseOrNull)
返回值: T
说明: 当条件testCondition为TRUE时,返回valueTrue;否则返回valueFalseOrNull
|
语法:COALESCE(T v1, T v2, …)
返回值: T
说明: 返回参数中的第一个非空值;如果所有值都为NULL,那么返回NULL
|
语法: CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END
返回值: T
说明:如果a等于b,那么返回c;如果a等于d,那么返回e;否则返回f
hive> Select
case
100
when
50 then
‘tom‘
when
100
then
‘mary‘
else
‘tim‘
end
from
tableName;
mary
hive> Select
case
200
when
50 then
‘tom‘
when
100
then
‘mary‘
else
‘tim‘
end
from
tableName;
tim
语法: CASE WHEN a THEN b [WHEN c THEN d]* [ELSE e] END
返回值: T
说明:如果a为TRUE,则返回b;如果c为TRUE,则返回d;否则返回e
hive> Select
case
when
1=2
then
‘tom‘
when
2=2 then
‘mary‘
else
‘tim‘
end
from
tableName;
mary
hive> Select
case
when
1=1
then
‘tom‘
when
2=2 then
‘mary‘
else
‘tim‘
end
from
tableName;
tom