hive函数
hive条件函数
(1)if函数:if(条件表达式,结果1,结果2)
hive> select if(1=2,100,200) from lxw_dual; 200 hive> select if(1=1,100,200) from lxw_dual; 100
(2)coalesce函数:返回参数中的第一个非空值;如果所有值都为null,那么返回null
hive> select COALESCE(null,‘100‘,‘50′) from lxw_dual; 100
(3)case when函数:
- CASE a WHEN b THEN c [WHENd THEN e]* [ELSE f] END
- 如果a等于b,那么返回c;如果a等于d,那么返回e;否则返回f
hive> Select case 100 when 50 then ‘tom‘ when 100 then ‘mary‘ else ‘tim‘ end from lxw_dual; mary hive> Select case 200 when 50 then ‘tom‘ when 100 then ‘mary‘ else ‘tim‘ end from lxw_dual; tim
- CASE WHEN a THEN b [WHEN cTHEN d]* [ELSE e] END
- 如果a为TRUE,则返回b;如果c为TRUE,则返回d;否则返回e
hive> select case when 1=2 then ‘tom‘ when 2=2 then ‘mary‘ else ‘tim‘ end from lxw_dual; mary hive> select case when 1=1 then ‘tom‘ when 2=2 then ‘mary‘ else ‘tim‘ end from lxw_dual; tom
相关推荐
成长之路 2020-07-28
taisenki 2020-07-05
SignalDu 2020-07-05
zlsdmx 2020-07-05
archive 2020-06-12
archive 2020-07-30
eternityzzy 2020-07-19
tugangkai 2020-07-05
tomson 2020-07-05
tugangkai 2020-07-04
tomson 2020-07-05
Zhangdragonfly 2020-06-28
genshengxiao 2020-06-26
成长之路 2020-06-26
tomson 2020-06-26
蜗牛之窝 2020-06-26