Impala 数值函数大全(转载)
官网:https://www.cloudera.com/documentation/enterprise/latest/topics/impala_math_functions.html
转载链接1:https://blog.csdn.net/qq_24699959/article/details/79863664
转载链接2:https://blog.csdn.net/qq_24699959/article/details/80090050
Impala SQL 语言元素(翻译):https://my.oschina.net/weiqingbin/blog/189413#OSC_h2_2
Impala数据类型:https://blog.csdn.net/yidu_fanchen/article/details/78295499
1、字符串截取substr,从1开始,而不是0;注意一个汉字长度是3
select brand,substr(brand,1,6) from dw_bill_his limit 10;

2、cast函数
cast(expr AS type), 类型转换函数, 比如将number转成string, 或相反.
select cast(length as int) len from dw_bill_his where length != '无' and startdate='2018-09-01' order by cast(length as int);
3、max,min,avg函数:length字段是字符串类型
select max(cast(length as int)) len from dw_bill_his where length!='无' and startdate='2018-09-01';
select min(cast(length as int)) len from dw_bill_his where length!='无' and startdate='2018-09-01';
select avg(cast(length as int)) len from dw_bill_his where length!='无' and startdate='2018-09-01';
4、截取数值,四舍五入
select dround(2.14123,3) result;

select dround(2.14123,2) result;

取整
select dround(2.14123) result;

5、删除所有小数点以后的数或删除N位小数
select truncate(3.45);

select truncate(3.456,1)

6、返回表达式列表中的最大值:greatest
select greatest(5,16,2) as greatest;

7、返回表达式列表中的最小值: least
select least(5,16,2) as least;

8、like 模糊查询
select count(*) from dw_bill_his where city='北京' and broadcastdate like '2018/03%';

9、字符串截取,substr(str,startindex,length) startindex从1开始
select substr('2018-08-20',1,4) year1;

10、字符串连接 concat(string a,string b…)
拼接多个字符串
--连接hello和world两个字符串
select concat('hello','world') as concat

concat_ws(string sep,string a,string b…)
拼接多个字符串,由指定分隔符分割
--通过'-'连接两个字符串
select concat_ws('-','hello','world') as concat_ws;

11、字符串长度 length(string a)
select length('world') as len;

12、给表增加一列:
ALTER TABLE name ADD COLUMNS (col_spec[, col_spec ...])
比如给表dw_bill增加一个float类型的week列
ALTER TABLE dw_bill ADD COLUMNS(week FLOAT);
13、删除一列
ALTER TABLE name DROP [COLUMN] column_name
比如删除dw_bill的week列表
ALTER TABLE dw_bill DROP week;
14、字符串去空格
去左空格: select ltrim(' hello ');
去右空格: select rtrim(' hello ');
去左右空格: select trim(' hello ');
15、查询某个字段为null的记录条数
select count(1) from dw_bill where brand is null;
不为null的记录条数
select count(1) from dw_bill where brand is not null;
Impala 数值函数大全(转载)的更多相关文章
- CSS颜色代码 颜色值 颜色名字大全(转载)
CSS颜色代码 颜色值 颜色名字大全 转载处http://flyjj.com/css-colour-code.html 颜色值 CSS 颜色使用组合了红绿蓝颜色值 (RGB) 的十六进制 (hex) ...
- mysql sql语句大全(转载)
1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- 创建 ...
- Impala 介绍(转载)
一.简介 1.概述 Impala是Cloudera公司推出,提供对HDFS.Hbase数据的高性能.低延迟的交互式SQL查询功能. •基于Hive使用内存计算,兼顾数据仓库.具有实时.批处理.多并发等 ...
- js数组操作大全(转载)
转载原网址:http://hi.baidu.com/jspboy/item/4923fffb52a28014fe35823a shift:删除原数组第一项,并返回删除元素的值:如果数组为空则返回und ...
- Mysql常用命令行大全——转载
转载地址:http://www.blogjava.net/supperchen/archive/2012/10/11/389340.html 第一招.mysql服务的启动和停止 net stop my ...
- js正则表达式验证大全--转载
转载来源:http://www.cnblogs.com/hai-ping/articles/2997538.html#undefined //判断输入内容是否为空 function IsNull(){ ...
- Git 常用命令大全-转载
一. Git 常用命令速查 git branch 查看本地所有分支git status 查看当前状态 git commit 提交 git branch -a 查看所有的分支git branch -r ...
- Eclipse快捷键大全(转载)
一.实用类快捷键 1 常用熟悉的快捷键 CTRL+C(复制).CTRL+X(剪切).CTRL+Z(撤销).CTRL+F(查找).CTRL+H(搜索文件或字符串).CTRL+Y(重做).CTRL+/(双 ...
- css颜色大全-转载
FFFFFF #DDDDDD #AAAAAA #888888 #666666 #444444 #000000 #FFB7DD #FF88C2 #FF44AA #FF0088 #C10066 #A ...
随机推荐
- hdu 5735 Born Slippy 暴力
Born Slippy 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5735 Description Professor Zhang has a r ...
- Linux下的sqlserver简单试用
微软自2017年就推出了可以在linux上使用的sql-server,最近接触到了一个用sqlserver的项目,便尝试使用了一下. 下载 为了简化安装,我还是使用的docker的方式,镜像可以直接从 ...
- Linux kernel AIO
http://blog.csdn.net/abcd1f2/article/details/47440087
- 坐标的相对转换ClientToScreen与ScreenToClient
假如一个有一个TEdit的实例edt_Position,edt_Position所在容器有好几层,所在的窗体为frmMain.现要弹出一个FORM,FORM的容器为frmMain,弹出的位置在edt_ ...
- 在ASP.NET Web API中实现CORS(跨域资源共享)
默认情况下,是不允许网页从不同的域访问服务器资源的,访问遵循"同源"策略的原则. 会遇到如下的报错: XMLHttpRequest cannot load http://local ...
- (转)java并发编程--Executor框架
本文转自https://www.cnblogs.com/MOBIN/p/5436482.html java并发编程--Executor框架 只要用到线程,就可以使用executor.,在开发中如果需要 ...
- Jquery 验证 validate
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
- Linux学习12-CentOS设置多个tomcat开机自启动
前言 一台服务器上有多个tomcat环境,重启服务器后,每次需要手动一个个启动服务,非常麻烦,于是可以设置tomcat开机自启动. tomcat开机自启动非常慢,可以修改jvm下配置解决tomcat开 ...
- MyBatis入参类型是List时判断非空
一.参数list时,先判断是否为空,否则会报错. 二.mybatis ${}与#{}的区别 简单来说#{} 解析的是占位符?可以防止SQL注入, 比如打印出来的语句 select * from tab ...
- 都铎王朝第一至四季/全集The Tudors迅雷下载
都铎王朝 第一.二.三.四季 The Tudors Season (2007-2010) 本季看点:本剧讲述了年轻的亨利八世对英国的统治以及他的婚姻生活,带有传奇色彩.Showtime电视台的古装热门 ...