HIVE SQL取整函数汇总

int()

向零取整,即向接近零的方向取整。

int(5.6)

输出:5

int(-5.6)

输出:-5

round(double a)

四舍五入取整

select round(5.6)

输出:6

select round(-5.6)

输出:-6

round(double a,int d)

指定精度四舍五入取整

select round(5.6667,2)

输出:5.67

select round(-5.6667,2)

输出:-5.67

扫描二维码关注公众号,回复: 17179941 查看本文章

floor()

向下取整
select floor(5.6)

输出:5

select floor(-5.6)

输出:-6

ceil()

向上取整
select ceil(5.6)

输出:6

select ceil(-5.6)

输出:-5

猜你喜欢

转载自blog.csdn.net/p1306252/article/details/134572332