聚合函数
count(*)
:统计行数(算null)count(col)
:统计列中非null值个数。max(col)/min(col)
:返回该列最大/小值。sum(col)
:该列所有值的和。avg(col)
:该列值的平均值。group_concat(col)
:按列值分组后,列值连接后的结果。
字符串函数
concat(s1, s2,...sn)
:连接字符串concat_ws(sep,s1,s2...,sn)
:将s1,s2…,sn连接成字符串,并用sep字符间隔locate(substr,str)/position(sub,str)
:返回substr在str中第一次出现的位置,没有则返回0。length(s)
:返回字符串str中的字符数。reverse(str)
: 返回颠倒字符串str的结果strcmp(s1,s2)
:比较字符串s1和s2trim(str)
:去除字符串首部和尾部的所有空格lcase(str)
或lower(str)
:返回将字符串str中所有字符改变为小写后的结果ucase(str)
或upper(str)
:返回将字符串str中所有字符转变为大写后的结果substring(s,n,len)
:从字符串s的n位置开始长度为len的子串。
日期
curdate()
或current_date()
:返回当前的日期curtime()
或current_time()
: 返回当前的时间now()
:当前日期+时间sql server : datediff(yy, 列表属性birthday, getdate())
:将当前日期与出生日期求差,格式yy,得年份即年龄。from_unixtime(时间戳, '%y-%m-%d')
:将时间戳转化为指定日期格式(时间戳10位,秒为单位)unix_timestamp('日期字符串')
:日期转化为时间戳,unix_timestamp(‘2019-11-02 12:20:00’)
其他
- 类型转换:
cast()