当前位置:网站首页>Data query of MySQL (aggregate function)
Data query of MySQL (aggregate function)
2022-07-26 12:18:00 【Yu'an.112】
SELECT The expression of clause can contain the so-called aggregate function (Aggregation Function). Aggregate functions are often used to calculate a set of values , And then return a single value . except COUNT() Out of function , Aggregate functions ignore null values . Aggregate functions are usually associated with GROUP BY Clauses are used together . if SELECT There is a GROUP BY Clause , Then the aggregate function works on all columns . If there is no , be SELECT Statement produces only one line as the result .
Common aggregate functions :
COUNT: Find the number of items in the group , return int Type integer
MAX: For maximum
MIN: For the minimum
SUM: Returns the sum of all values in an expression
AVG: Find the average of the group median
1、COUNT() function
The most commonly used in aggregate functions is COUNT() function , It is used to count the number of rows or total rows that meet the conditions in the table , return SELECT Statement retrieves rows that are not NULL The number of values , If no match is found , Then return to 0.
The grammar format is :COUNT( { [ALL | DISTINCT] expression } | *)
example : Ask the total number of members
SELECT COUNT(*)AS ' Number of members '
FROM Members;example : Count the number of closed orders
SELECT COUNT( Whether to settle )AS' Number of orders closed '
FROM Sell;2、MAX() Functions and MIN() function
MAX and MIN Functions are used to find the maximum and minimum values of all value items in the expression
Grammar format :MAX / MIN ([ALL | DISTINCT] expression )
example : Please order the book number IS-001 The maximum number of orders and the minimum number of orders
SELECT MAX( Number of copies ordered ),MIN( Number of copies ordered )
FROM Sell
WHERE Book number ='IS-001';3、SUM() Functions and AVG() function
SUM and AVG Respectively used to find the sum and average of all value items in the expression
Grammar format :SUM / AVG ( [ ALL | DISTINCT ] expression )
example : Please order the book number IS-01 The total number of books ordered
SELECT SUM( Number of copies ordered )AS' Total number of copies ordered '
FROM Sell
WHERE Book number ='IS-01';example : Please order books with the number IS-02 The average number of books ordered
SELECT AVG( Number of copies ordered )AS' The average number of copies per order '
FROM Sell
WHERE Book number ='IS-02';边栏推荐
- Pytest interface automation test framework | rerun failed cases
- Who is responsible for the problems of virtual idol endorsement products? And listen to the lawyer's analysis
- 2022就业季!Adobe助力创意产业工作者,突破技能桎梏,回归能力本源
- 向日葵远程控制为何采用BGP服务器?自动最优路线、跨运营商高速传输
- Flutter JNI confusion introduction.So file release package flash back
- 大佬们,请教一下,我按照文档配了cdc连接oracle,总是运行报错找不到类 ValidstionE
- 字节流习题遇到的问题及解决方法
- 一些常用的文章写作使用方法和技巧
- 10. 509. Introduction to PKCs file format
- 【Map】万能的Map使用方法 & 模糊查询的两种方式
猜你喜欢

CVPR 2022 new SOTA for monocular depth estimation new CRFs: neural window fullyconnected CRFs

SSJ-21B时间继电器

Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators

Detailed explanation of Legendre transformation and conjugate function

DS-24C/DC220V时间继电器

Li Kai: the interesting and cutting-edge audio and video industry has always attracted me

11 "pocket" universities in China! Running on campus and leaving the school before accelerating

On the construction and management of low code technology in logistics transportation platform

el-form 每行显示两列,底部按钮居中

Ssj-21b time relay
随机推荐
Hou Peixin, chairman of the openharmony Working Committee of the open atom open source foundation, sent a message to the openatom openharmony sub forum
DS-24C/DC220V时间继电器
《多线程下ThreadLocal使用场景实例》
Flink 在 讯飞 AI 营销业务的实时数据分析实践
自定义浏览器默认右击菜单栏
Sim900a based on STM32 sends short messages in Chinese and English
Redis实现Single单点登入--系统框架搭建(一)
二、容器_
面试京东T5,被按在地上摩擦,鬼知道我经历了什么?
敲黑板画重点:七种常见“分布式事务”详解
JSJ-3/AC220V时间继电器
How much do you know about the two infrastructures of the badminton stadium?
行业案例|指标中台如何助力银行业普惠金融可持续发展
【2243】module_param.m
扫雷小游戏——轻松玩上瘾(C语言版)
[map] universal map usage & two ways of fuzzy query
Customize browser default right-click menu bar
File类的学习过程中出现的问题及解决方法
Redisson分布式锁流程详解(二)
uniapp h5、app引用外部在线js