zoukankan      html  css  js  c++  java
  • hive查询

    空字段赋值:NVL    给值为null的数据赋值

      select nvl(age,20) from t_preson;

    时间类:

    date_format:格式化时间

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

    date_add:时间和天数相加

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

    date_diff:两个时间相减

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

    case when then

      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

  • 相关阅读:
    prev()方法使用的注意点
    JS 获取图片的高度
    渐变色
    JS获取时间
    监听鼠标上下滚动事件
    几种常见的边框样式
    左侧导航背景颜色随机变化
    apache开启gzip压缩
    dedecms在linux上安装提示没权限解决办法
    阿里云centos7.3安装lamp环境
  • 原文地址:https://www.cnblogs.com/saber-xi/p/13137740.html
Copyright © 2011-2022 走看看