impala sql

Analytic:

cume_dist() over (order by ) :全表小于或等于该记录的数据和总记录数的比

lag()  over(partition by):取指定字段的上条记录的值

lead()over(partition by):取指定字段的下条记录的值

ntile(n)over(order by) :指定字段在所有记录里的1/n

percent()over(partition by):百分比

Date:

current_timestamp()和now()等价:当前时间戳

from_unixtime():转为unix时间 

unix_timestamp():转为unix时间戳

求时间差(先转为秒数求差,分钟同理:select from_unixtime(timestamp1)-from_unixtime(timestamp2)

转为时间戳(注意时间格式的大小写:from_timestamp('2019-11-12','yyyy/MM/dd HH:mm:ss:SSSSSS')

date_add('2019-10-10',3):三天后

date_sub('2019-10-10',3)等价于subdate('2019-10-10',3):三天前

datediff(new,old):日期间隔

timestamp_cmp(new,old):时间戳求差,结果为天数差

dayofweek:一个星期的第几天(国外星期天是第一天)

String:

base64decode(string str) : base64 解码.
base64encode(string str) : base64 编码.

concat_ws('-', 'a', 'b',...):按照指定分隔符拼接字符串

find_in_set(string str, string strList):在以逗号分隔的字符串列表 strList 中查找字符串, 结果为列表的下标, 下标起始为 1, 没找到的话为 0, 如果两个参数有一个为 null, 返回值为 null.

TypeConversion:

cast(): cast('1' as BIGINT)

发布了25 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/kimi_Christmas/article/details/103288730