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 ...
随机推荐
- OpenStack Juno 版本发布——支持Spark和NFV[转]
作者:郑晨,OpenStack中国社区,转载请注明出处 美国时间2014年10月16日,OpenStack Juno版本正式发布,这是OpenStack开源云计算项目自2010年创立以来的第10个版本 ...
- BZOJ1768 : [Ceoi2009]logs
从上到下枚举行,可以$O(m)$更新现在每一列往上连续的1的个数,也可以在$O(m)$的时间内完成排序.总复杂度$O(nm)$. #include<cstdio> #define M 15 ...
- SNOI 滚粗记
连睡觉都只能睡一半就吓醒 真的蠢 CE了四道 没有cstring 踏马本机怎么能过??!! 还有几次夏令营什么的 可能水水就结束了 最单纯的拿点优惠的想法也没实现 都说以后会有用的 大概是吧 也大概是 ...
- 使用Xcode打包上传APP
1.打开xcode,进入product->Scheme->EditScheme,找到Archive,最上面的设备选择IOSDevice,在BuildConfiguration中选中Rele ...
- Linux 网络流量实时监控工具之ntopng详解
大纲一.前言二.ntopng 简介三.ntopng 功能说明 四.ntopng 安装详解五.ntopng 配置详解 六.ntopng 使用详解注,操作系统 CentOS 5.5 X86_64,软件版本 ...
- PDCA管理方法论
PDCA管理方法论 PDCA管理循环,由日本的高管们在1950年日本科学家和工程师联盟研讨班上学到的戴明环改造而成,最先是由休哈特博士提出来的,由戴明把PDCA发扬光大,并且用到质量领域,故称为质量环 ...
- HDU 4813 Hard Code(水题,2013年长春现场赛A题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4813 签到题. 把一个字符串按照格式输出就可以了,很水 #include <stdio.h> ...
- General PE format layout
- [Go] 子类 调用 父类 的 属性、方法
package main import ( "fmt" ) type A struct { Text string Name string } func (a *A) Say() ...
- 利用阿里云提供的镜像快速更换本地的yum源
打开网页:http://mirrors.aliyun.com/ 从“ 文件列表 ”找到自己的系统: Mirror Last update Help CPAN 2015-07-15 15:36:50 ...