官网: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 数值函数大全(转载)的更多相关文章

  1. CSS颜色代码 颜色值 颜色名字大全(转载)

    CSS颜色代码 颜色值 颜色名字大全 转载处http://flyjj.com/css-colour-code.html 颜色值 CSS 颜色使用组合了红绿蓝颜色值 (RGB) 的十六进制 (hex) ...

  2. mysql sql语句大全(转载)

      1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3.说明:备份sql server --- 创建 ...

  3. Impala 介绍(转载)

    一.简介 1.概述 Impala是Cloudera公司推出,提供对HDFS.Hbase数据的高性能.低延迟的交互式SQL查询功能. •基于Hive使用内存计算,兼顾数据仓库.具有实时.批处理.多并发等 ...

  4. js数组操作大全(转载)

    转载原网址:http://hi.baidu.com/jspboy/item/4923fffb52a28014fe35823a shift:删除原数组第一项,并返回删除元素的值:如果数组为空则返回und ...

  5. Mysql常用命令行大全——转载

    转载地址:http://www.blogjava.net/supperchen/archive/2012/10/11/389340.html 第一招.mysql服务的启动和停止 net stop my ...

  6. js正则表达式验证大全--转载

    转载来源:http://www.cnblogs.com/hai-ping/articles/2997538.html#undefined //判断输入内容是否为空 function IsNull(){ ...

  7. Git 常用命令大全-转载

    一. Git 常用命令速查 git branch 查看本地所有分支git status 查看当前状态 git commit 提交 git branch -a 查看所有的分支git branch -r ...

  8. Eclipse快捷键大全(转载)

    一.实用类快捷键 1 常用熟悉的快捷键 CTRL+C(复制).CTRL+X(剪切).CTRL+Z(撤销).CTRL+F(查找).CTRL+H(搜索文件或字符串).CTRL+Y(重做).CTRL+/(双 ...

  9. css颜色大全-转载

    FFFFFF #DDDDDD #AAAAAA #888888 #666666 #444444 #000000 #FFB7DD #FF88C2 #FF44AA  #FF0088  #C10066  #A ...

随机推荐

  1. Xcode 模拟器复制解决方案

    网址:http://blog.csdn.net/zhangao0086/article/details/38491271

  2. OpenNI2 + NiTE2开发教程

    发现了一个非常不错的关于自然交互OpeNI2+NiTE2的资源,非常感谢Heresy,这里分享链接: OpenNI 2.x 教学文章(转载自:Heresy博客,地址:https://kheresy.w ...

  3. 关于 TRegEx.Split()

    表达式中的括号将严重影响分割结果. uses RegularExpressions; const FSourceText = '1: AAA 2: BBB 3: CCC'; // 分隔符将有三部分构成 ...

  4. VSCode换行符

    如果要显示换行符:\r\n 如果要替换显示出来的\n,替换上要用正则表达式,然后使用\r\n. 如果要直接换行,\n

  5. CentOS 7搭建KVM在线管理面板WebVirtMgr

    系统版本:CentOS 7.4 WebVirtMgr版本:master分支的20180720版本,下载链接(链接:https://pan.baidu.com/s/1kl060hPHDGbwJUR_iM ...

  6. IOS-UITableView入门(2)

    1.对于TableView .每一个item的视图基本都是一样的. 不同的仅仅有数据. IOS提供了一种缓存视图跟数据的方法.在 -UITableViewCell *) tableView:cellF ...

  7. 《Go语言实战》摘录:6.5 并发 - 通道

    6.5 通道

  8. 对 Git 分支 master 和 origin/master 的一些认识

    首先要明确一点,对 Git 的操作是围绕 3 个大的步骤来展开的(其实几乎所有的 SCM 都是这样) 从 git 取数据(git clone) 改动代码 将改动传回 git(git push) 这 3 ...

  9. 对数据集“dsArea”执行查询失败。 (rsErrorExecutingCommand),Query execution failed for dataset 'dsArea'. (rsErrorExecutingCommand),Manually process the TFS data warehouse and analysis services cube

    错误提示: 处理报表时出错. (rsProcessingAborted)对数据集“dsArea”执行查询失败. (rsErrorExecutingCommand)Team System 多维数据集或者 ...

  10. URAL 1837. Isenbaev's Number (map + Dijkstra || BFS)

    1837. Isenbaev's Number Time limit: 0.5 second Memory limit: 64 MB Vladislav Isenbaev is a two-time ...