当前位置:网站首页>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
边栏推荐
- "One good programmer is worth five ordinary programmers!"
- mysql查询时间戳转换成日期格式
- 汇编语言(2)基础知识-debug
- Fan benefits, JVM manual (including PDF)
- [untitled]
- WinXP内核驱动调试
- Reading notes at night -- deep into virtual function
- Tianshu night reading notes -- disassembly engine xde32
- 利用 Redis 的 sorted set 做每周热评的功能
- 联想童夫尧:11倍于大势,我们一路攻城拔寨
猜你喜欢

Tianshu night reading notes -- memory paging mechanism

Bi SQL drop & alter

Première application de l'informatique quantique à la modélisation des flux de puissance dans les systèmes énergétiques à l'Université technique danoise

Powerbi - for you who are learning

Fan benefits, JVM manual (including PDF)

15.线程同步的几种方法

Bi SQL alias

Abnova丨A4GNT多克隆抗体中英文说明

Boutique enterprise class powerbi application pipeline deployment

4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
随机推荐
Which securities company should I choose to open an account online? Is it safe to open an account online?
国内炒股开户正规安全的具体名单
粉丝福利,JVM 手册(包含 PDF)
[live review] 2022 Tencent cloud future community city operator recruitment conference and SaaS 2.0 new product launch!
天书夜读笔记——8.4 diskperf反汇编
Use redis' sorted set to make weekly hot Reviews
How much commission does CICC wealth securities open an account? Is stock account opening and trading safe and reliable?
Novice, let me show you the "soft test" at one time
Convolution and transpose convolution
C language boundary calculation and asymmetric boundary
Q1季度逆势增长的华为笔电,正引领PC进入“智慧办公”时代
Bi-sql top
IPC机制
新手看过来,带你一次性了解“软考”
[untitled]
广发期货安全吗?开户需要什么东西?
Programmer: did you spend all your savings to buy a house in Shenzhen? Or return to Changsha to live a "surplus" life?
mysql查询时间戳转换成日期格式
Tencent cloud wecity Hello 2022!
vb学习什么[通俗易懂]