码迷,mamicode.com
首页 > 其他好文 > 详细

hive中的常用方法(case,cast,unix_timestamp)

时间:2016-11-18 22:41:13      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:blog   http   ble   nbsp   create   val   select   记录   name   

1.case的用法

  )格式1

    case col

    when value then ‘‘

    when value then ‘‘

    else 

      ‘‘

    end

  )格式2

    case

    when col=‘value‘ then ‘‘

    when col=‘value‘ then ‘‘

    else

      ‘‘

    end

  )举例

  技术分享

2.cast

  作用:转换

  )格式

    cast(col as type)

  

  )举例

    create table catstest as select empno,ename,cast(sal as string) salary from emp;

 

3.unix_timestamp

  作用:记录时间格式

     统计从1970年开始到现在的秒数

    技术分享

 

hive中的常用方法(case,cast,unix_timestamp)

标签:blog   http   ble   nbsp   create   val   select   记录   name   

原文地址:http://www.cnblogs.com/juncaoit/p/6078748.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!