官网: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. ZOJ 2975 Kinds of Fuwas

    K - Kinds of Fuwas Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu De ...

  2. c# dapper mysql like 参数化

    //拼接sql语句: if (!string.IsNullOrEmpty(model.Email)) { where += " and a.email like @email "; ...

  3. Spring_错误 java.sql.SQLException: Lock wait timeout exceeded | CannotAcquireLockException 的解决

    java.sql.SQLException: Lock wait timeout exceeded |  org.springframework.dao.CannotAcquireLockExcept ...

  4. C#——性能计数器

    简要Windows性能监视器: 打开Windows性能监视器的步骤如下: 开始→运行→perfmon→确定 在这里我们可以选择添加我们要监控的计数器,比如:cpu使用率.内存使用量等,作为asp.ne ...

  5. CF330 C. Purification 认真想后就成水题了

    C. Purification time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  6. select,poll,epoll之间的区别

    (1)select,poll实现需要自己不断轮询所有fd集合,直到设备就绪,期间可能要睡眠和唤醒多次交替.而epoll其实也需要调用epoll_wait不断轮询就绪链表,期间也可能多次睡眠和唤醒交替, ...

  7. ASP.NET Web API基于OData的增删改查,以及处理实体间关系

    本篇体验实现ASP.NET Web API基于OData的增删改查,以及处理实体间的关系. 首先是比较典型的一对多关系,Supplier和Product. public class Product { ...

  8. .NET对象的创建、垃圾回收、非托管资源的手动处理

    本篇用来梳理对象的创建.垃圾的回收,以及非托管资源的手动处理. →首先运行应用程序,创建一个Windows进程. →CLR创建一块连续的虚拟地址空间,这个地址空间就是托管堆.而且,这个地址空间最初并没 ...

  9. C语言控制结构

    C语言流程控制 一.流程控制结构 (1)顺序结构:按书写顺序执行每一条语句. (2)选择结构:对给定的条件进行判断,根据判断结果决定执行哪一段代码. (3)循环结构:在给定条件成立的情况下,反复执行某 ...

  10. YII框架分析笔记2:组件和事件行为管理

    Yii是一个基于组件.用于开发大型 Web 应用的高性能 PHP 框架.CComponent几乎是所有类的基类,它控制着组件与事件的管理,其方法与属性如下,私有变量$_e数据存放事件(evnet,有些 ...