当前位置:网站首页>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成为首批创新联合体(信创)成员单位

Zuckerberg demonstrated four VR head display prototypes, and meta revealed the "family" of metauniverse

TC对象结构和简称

Bi-sql index

Use redis' sorted set to make weekly hot Reviews

Ideas and examples of divide and conquer

明日考试 最后一天如何备考?二造考点攻略全整理

pbcms添加循环数字标签

Boutique enterprise class powerbi application pipeline deployment

汇编语言(4)函数传参
随机推荐
Bi-sql - join
"One good programmer is worth five ordinary programmers!"
卷积与转置卷积
修身励学篇
胰蛋白酶中英文说明书
Lenovo tongfuyao: 11 times the general trend, we attacked the city and pulled out the stronghold all the way
Bi-sql delete
How much commission does CICC wealth securities open an account? Is stock account opening and trading safe and reliable?
Contentresolver, get the SMS content
VB learning notes
sql 聚合函数对 null 的处理[通俗易懂]
Bi SQL alias
数组中关于sizeof()和strlen
Ecological escort cloud service providers wave "Intel flag"
Why does Dell always refuse to push the ultra-thin commercial notebook to the extreme?
Bi SQL drop & alter
Library management system code source code (php+css+js+mysql) complete code source code
JVM directive
Boutique enterprise class powerbi application pipeline deployment
TC对象结构和简称