hive对有null值的列进行avg,sum,count等操作时会不会过滤null值
在hive中,我们经常会遇到对某列进行count、sum、avg等操作计算记录数、求和、求平均值等,但这列经常会出现有null值的情况,那这些操作会不会过滤掉null能呢?
下面我们简单测试下:
with tmp as
(
select null as col1
union all
select 666 as col1
union all
select 999 as col1
)
select avg(col1) avg_numm, sum(col1) sum_num, count(1) cnt, count(col1) cnt_col1
from tmp
832.5 1665 3 2
1
2
3
4
5
6
7
8
9
10
11
12
从结果中很容易得出结论:avg、sum、count都会过滤掉null值
---------------------
hive对有null值的列进行avg,sum,count等操作时会不会过滤null值的更多相关文章
- 操作MyBatis引发Error setting null for parameter #X with JdbcType OTHER .无效的列类型
再用MyBatis操作Oracle的时候,传入null值而引发的错误 异常信息: org.springframework.jdbc.UncategorizedSQLException: Error s ...
- SQL查询数据库表字段值不为空或Null的所有列
) set @TableName = 'Agency' -- 表名 declare @querySql nvarchar(max) set @querySql = 'select ' ) declar ...
- 【SQL Server 学习系列】-- SQL查询数据库表字段值不为空或Null的所有列
) set @TableName = 'Agency' -- 表名 declare @querySql nvarchar(max) set @querySql = 'select ' ) declar ...
- Hive分区表新增字段及修改表名,列名,列注释,表注释,增加列,调整列顺序,属性名等操作
一.Hive分区表新增字段 参考博客:https://blog.csdn.net/yeweiouyang/article/details/44851459 二.Hive修改表名,列名,列注释,表注释, ...
- 大数据量表中,增加一个NOT NULL的新列
这次,发布清洗列表功能,需要对数据库进行升级.MailingList表加个IfCleaning字段,所有的t_User*表加个IfCleaned字段. 脚本如下 对所有的t_User表执行 a ...
- SSAS 度量值中的distinct count局聚合方式会数为null的值
我们来看一个例子 Analysis Services: For Distinct Count measure NULL = 0 If you are to look at the table of v ...
- SQL中AVG、COUNT、SUM、MAX等聚合函数对NULL值的处理
一.AVG() 求平均值注意AVE()忽略NULL值,而不是将其作为“0”参与计算 二.COUNT() 两种用法 1.COUNT(*) 对表中行数进行计数不管是否有NULL 2.COUNT(字段名) ...
- jackson 转json. 过滤null值
@Test public void tttttt() throws JsonGenerationException, JsonMappingException, IOException { Objec ...
- jqgrid取所有行的值,jqgrid取行对应列(name)的值,jqgrid取多行值对应列转json的方法
1.jqgrid取所有行的值(#gridTable指对应table的ID) var obj = $("#gridTable").jqGrid("getRowData&qu ...
随机推荐
- 51nod1043(数位dp)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1043 题意:中文题诶- 思路:数位dp 我们用dp[i][j ...
- 二维偏序 tree
tree(二维偏序) 最近接触到一些偏序的东西. 传统线段树非叶子节点的划分点mid=(l+r)/2,但小R线段树mid是自己定的.但满足l<=mid<r,其余条件同原来线段树.那么不难发 ...
- 洛谷P3043 [USACO12JAN]牛联盟Bovine Alliance
P3043 [USACO12JAN]牛联盟Bovine Alliance 题目描述 Bessie and her bovine pals from nearby farms have finally ...
- 2017-10-17 NOIP模拟赛
Reverse #include<iostream> #include<cstdio> #include<cstring> using namespace std; ...
- 原来C#可以直接写二进制数的
二进制数在C#中的写法: byte b=0b01111110 二进制字符串的解释: string bstr="0111110"; byte b=Convert.ToByte(bst ...
- React学习记录
托webpack的福,我终于可以开始写React了.==ORZ 我感觉我接近webpack工程师更进一步了哈哈哈. 以下所有内容均来自小红书,仅是我的个人记录,如想系统学习,请移步:React小书 : ...
- CodeForces - 186A-Comparing Strings
Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses ...
- 物理机和虚拟机互相可以ping通,还是无法连接
关闭防火墙服务 CentOS # systemctl stop firewalld.service Debian # iptables -F Ubuntu # ufw disable 安装SSH服务 ...
- POJ - 3461 (kmp)
题目链接:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS Memory Limit: 65536K Total Submissio ...
- leetcoe--47. Permutations II
1.问题描述 Given a collection of numbers that might contain duplicates, return all possible unique permu ...