MYSQL Basics to Know…..PART-3
MYSQL Basics to Know…..PART-3
AGGREGATE FUNCTIONS — collects a set of values to return a single value.
![](https://miro.medium.com/max/344/1*2e7AvICL3DQLvyopaO2qBA.png)
I have used my favorite comic data in creating a database and a table.
- The Vision, Volume 1: Little Worse Than A Man
- Batman: The killing Joke
- Venom, Volume 1: Homecoming
- Venom, Volume 2: The Abyss
- The Flash: A Celebration of 75 Years
COUNT(): counts the number of rows in a database.
![](https://miro.medium.com/max/700/1*JwjLl85JeeCG-Y0YGij52A.png)
![](https://miro.medium.com/max/446/1*bmMahiG6uRjiYj3X5bX9Pg.png)
MIN(): It shows the lowest number of values in a table.
![](https://miro.medium.com/max/384/1*Vzllv0A9VgqK8VJ2wSPTzg.png)
MAX(): It shows the highest number of values in a table.
![](https://miro.medium.com/max/329/1*OLApiE7_D9Fq5-tTOWFAXQ.png)
For MIN Title and pages. In this below syntax, it shows only Title and pages which is in ascending order and has a LIMIT -1 (which gives only 1 row of data).
![](https://miro.medium.com/max/376/1*OdJZ86PCWLE-hxsF3Hvj4Q.png)
The below syntax is based on descending order which can be also used for MAX() syntax.
![](https://miro.medium.com/max/372/1*lW6led6YaijT9e6xrt0XCA.png)
SUM(): It calculates the sum of a selected set of columns.
![](https://miro.medium.com/max/290/1*10MWq4eUlvAqA8vjFPODyw.png)
AVG(): It calculates the average of a selected set of columns.
![](https://miro.medium.com/max/382/1*VDZ3wjTZB7JzjWRKGNG7eQ.png)
Comments
Post a Comment