当前位置:网站首页>SQL aggregate function handling null [easy to understand]
SQL aggregate function handling null [easy to understand]
2022-06-25 01:22:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Aggregate functions
Count type (count)
SELECT COUNT(*)
FROM (
SELECT 1 AS num
UNION ALL
SELECT 1 AS num
UNION ALL
SELECT 2 AS num
UNION ALL
SELECT NULL AS num
)
;
SELECT COUNT(num)
FROM (
SELECT 1 AS num
UNION ALL
SELECT 1 AS num
UNION ALL
SELECT 2 AS num
UNION ALL
SELECT NULL AS num
)
;
The two results are 4 and 3
count(*) and count(column) The difference can be seen in the previous article
meanwhile sum(column) Will also be ignored directly null value
Mathematical functions ( variance :var_pop Standard deviation :stddev etc. )
SELECT var_pop(num)
FROM (
SELECT 3 AS num
UNION ALL
SELECT 6 AS num
UNION ALL
SELECT 9 AS num
UNION ALL
SELECT NULL AS num
)
;
SELECT stddev(num)
FROM (
SELECT 3 AS num
UNION ALL
SELECT 6 AS num
UNION ALL
SELECT 9 AS num
UNION ALL
SELECT NULL AS num
)
;
The two results are 6.0 and 2.449489742783178
[3 6 9] The variance of 6 , The standard deviation is 6 The square root of
The comparison of the two results shows that , Also directly ignore null It's worth it , Not as 0 Handle
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151860.html Link to the original text :https://javaforall.cn
边栏推荐
- Redis and jedis
- Tencent moved!
- 程序员:是花光积蓄在深圳买房?还是回到长沙过“富余”生活?
- Transform BeanUtils to achieve list data copy gracefully
- 腾讯云WeCity解决方案
- Start service 11111
- 高考之后,必然会出现以下四种情况:
- How to store dataframe data in pandas into MySQL
- LLVM TargetPassConfig
- After the college entrance examination, the following four situations will inevitably occur:
猜你喜欢
论文翻译 | RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds
Bi-sql Union
Tianshu night reading notes -- memory paging mechanism
1. 封装自己的脚手架 2.创建代码模块
百度语音合成语音文件并在网站中展示
程序员:是花光积蓄在深圳买房?还是回到长沙过“富余”生活?
修身励学篇
Bi SQL constraints
PMP考试“临门一脚”如何踢得漂亮?
Reading notes at night -- deep into virtual function
随机推荐
Fan benefits, JVM manual (including PDF)
php easywechat 和 小程序 实现 长久订阅消息推送
This national day! Tencent cloud wecity will accompany you to travel and light up the city landmark
天书夜读笔记——反汇编引擎xde32
Expectation and variance
How to store dataframe data in pandas into MySQL
lnmp环境安装ffmpeg,并在Yii2中使用
【直播回顾】2022腾讯云未来社区城市运营方招募会暨SaaS 2.0新品发布会!
4年工作經驗,多線程間的5種通信方式都說不出來,你敢信?
明日考试 最后一天如何备考?二造考点攻略全整理
天书夜读笔记——内存分页机制
AUTOCAD——两种延伸方式
PHP 利用getid3 获取mp3、mp4、wav等媒体文件时长等数据
Merge sort template & understanding
Tencent cloud wecity solution
卷积与转置卷积
生态护航 云服务商挥起“英特尔大旗”
Transform BeanUtils to achieve list data copy gracefully
百度语音合成语音文件并在网站中展示
动手学数据分析 数据建模和模型评估