MySQL Aggregate function (Sum,Avg &Count) || MySQL Tutorial

Опубликовано: 23 Май 2026
на канале: Code With Neha
1,369
38

On my previous video of mysql series
I have discussed about aggregate min max function
You can check the video from the above I button
Today's we will be discussing about count,avg and sum aggregate functions in mysql

Count aggregate function

The COUNT() function returns the number of rows that matches a specified criterion.

Syntax

SELECT COUNT(column_name)
FROM table_name
WHERE condition;


Avg aggregate function

The AVG() function returns the average value of a numeric column.

Syntax

SELECT AVG(column_name)
FROM table_name
WHERE condition;



Sum aggregate function

The SUM() function returns the total sum of a numeric column.

Syntax

SELECT SUM(column_name)
FROM table_name
WHERE condition;


Let us see with an example

Here we are using products table under order_info
Just as we did in our previous video

To find the no of products

Select count(ProductId)
From products

Query to find avg price of all products

Select avg(price)
From products

To find the sum of the prices of all products

Select sum(price)
From products


Let us more examples

To find the no of products where the productname is not null

Select count(Productname)
From products

To find the number of products where price is more than 19

Select count(Productname)
From products
Where price is more than =19
1
To find the no of prices whose supplierid is 2

Select sum(price)
From products
Where supplierId =2



And that's all for today Hope you all will get some help from this video
If it's so then don't forget to subscribe my channel Code with Neha and press the Bell Icon for Regular Updates
See you in the next video till then Stay Safe Stay Happy!!!



#aggregatefunctions
#aggregatefunctionsinsql
#sqlaggregatefunctionssum
#sqlaggregatefunctionavg
#sqlaggregatefunctioncount
#aggregatefunctionssql
#aggregatefunctionsindbms
#aggregatefunctionsmysql
#aggregatefunctionsinmysql
#sqlaggregatefunctions
#sqlaggregatefunctionstutorial
#mysqlcountfunction
#mysqlaggregatefunctions