当前位置:网站首页>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
边栏推荐
- 海河实验室创新联合体成立 GBASE成为首批创新联合体(信创)成员单位
- Linux64Bit下安装MySQL5.6-不能修改root密码
- Tencent cloud wecity solution
- sql 聚合函数有哪些
- 4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
- Properties of DOM
- 论文翻译 | RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds
- 卷积与反卷积关系超详细说明及推导(反卷积又称转置卷积、分数步长卷积)
- 联想童夫尧:11倍于大势,我们一路攻城拔寨
- Program.launch(xxx)打开文件
猜你喜欢

论文翻译 | RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds

Danish Technical University pioneered the application of quantum computing to power flow modeling of energy system

"One good programmer is worth five ordinary programmers!"

AutoCAD - two extension modes

4 ans d'expérience de travail, 5 modes de communication Multi - thread ne peuvent pas être décrits, vous osez croire?

js数组对象转对象

Using macro code to generate handwriting automatically in word or WPS

LLVM TargetPassConfig

Abnova丨CSV 磁珠中英文说明

2种常见的设备稼动率OEE监测方法
随机推荐
Fan benefits, JVM manual (including PDF)
Bi-sql select into
Welcome to the new world of Lenovo smart screen
Introduction to bi-sql wildcards
4年工作經驗,多線程間的5種通信方式都說不出來,你敢信?
Mysql database Chapter 1 Summary
VB 学习笔记
Reverse ordinal number by merge sort
Tianshu night reading notes -- memory paging mechanism
为猪脸识别而进行自己数据集的构建、训练「建议收藏」
中金财富证券开户佣金多少呢?股票开户交易安全靠谱吗?
php easywechat 和 小程序 实现 长久订阅消息推送
用手机在同花顺上开户靠谱吗?这样炒股有没有什么安全隐患
Convert MySQL query timestamp to date format
PHP easywechat and applet realize long-term subscription message push
Q1季度逆势增长的华为笔电,正引领PC进入“智慧办公”时代
Bi-sql - join
Assembly language (4) function transfer parameters
Tencent cloud wecity solution
Cobalt Strike安装教程