hive查詢

空字段賦值:NVL    給值爲null的數據賦值json

  select nvl(age,20) from t_preson;orm

時間類:字符串

date_format:格式化時間table

  select date_format(time,''yyyy-MM-dd") ;form

date_add:時間和天數相加date

  select date_add('2020-06-01',-5);select

date_diff:兩個時間相減im

  select datediff('2020-06-01','2020-06-01');數據

 

case when thenword

  select

    id,

    sum( sex when '男' then 1 else 0),

    sum(sex when '女' then 1 else 0)

    from emp_sex group by id

 

if 

  select

    id,

    sum(if(sex='男',1,0)),

    sum(if(sex='女',1,0))

    from emp_sex group by id

concat :字符串拼接,列拼接,支持多列傳入

  select concat('hello','-','word')

  select concat(id,num,age) from t_person

concat_ws:

  select concat('-,'hello','word','c') 

collect_set:某個字段值去重彙總,多用於json解析

explode:將一列數據拆成多列

laterral view:

  select book,category_book

  from bool

  lateral view

  explode(category) table_tmp as category_book

相關文章
相關標籤/搜索