Aggregate Functions
Hey
guys welcome to our new and first blog post of the year 2020 and this is also a
very special blog because again in this blog i will cover most of the topics of
SQL.
In Previous Blog -
In
previous Blog we learn about the Like command , group by command and order by
command of SQL and quickly lets revise the like command , group by command and
order by command of SQL so that we can start our blog as soon as earliest .
In Today’s Blog
In
today’s blog we learn about aggregate functions in SQL.
There
are many aggregate functions In SQL which can be used any time and very easily.
Aggregate Functions –
1 – Sum2 – Count3 – Maximum4 – Minimum5 – Average
Let’s
Discuss About these aggregate functions –
1 – Sum
As
you know that the meaning of sum is to add something in another thing so this
sum function will also work as the normal word sum means but in SQL the sum
function in use with select command.
Suppose
there is a table named smartphones and in the table there is a column named
price so we need to calculate the sum of price of all smartphones listed in the
table smartphone –
General
sum function command –
Select
sum ( < column name > ) from < table name > ;
But
according to the the question we need to enter the
command as –
Select
sum ( price ) from smartphone ;
2- Count Function
Count
function is used to count the number of rows in a particular column and it is
also used to calculate the total number of records in the table so the general
count function command is –
SELECT
COUNT * < COLUMN NAME > FROM < TABLE NAME > ;
Here
the * represents all means count all the records if we need to calculate
another thing then we need to enter the name of that thing instead of * .
Suppose
there is a table named student and in that table we need to count the total
number of students so we need to use the command as –
SELECT
COUNT * NAME FROM STUDENTS ;
Here
the * represents all and the name is the column name of the table and the students
is the table name so we enter the command as shown in the table .
3 - Maximum Function
Maximum
function is used to display the maximum value in the table it is very helpful
to find the maximum value in the table .
To
use the maximum function we need to enter the command as –
SELECT
MAX ( COLUMN NAME ) FROM < TABLE NAME
> ;
Suppose
there is a table named employees and in that table there is a table named
salary and in that table we need to display the maximum salary in the table so
we need to enter the maximum command as –
SELECT
MAX ( SALARY ) FROM EMPLOYEES ;
4 - Minimum Function
Minimum
function is used to display the minimum value in the table it is very helpful
to find the minimum value in the table .
To
use the minimum function we need to enter the command as –
SELECT
MIN ( COLUMN NAME ) FROM < TABLE NAME
> ;
Suppose
there is a table named employees and in that table there is a table named
salary and in that table we need to display the minimum salary in the table so
we need to enter the minimum command as –
SELECT
MIN ( SALARY ) FROM EMPLOYEES ;
5 – Average function
Average
function is used to calculate the average of the values in the table it is very
helpful function to calculate the average values in the table .
To
use average function command we need to enter the average function command as –
SELECT
AVG < COLUMN NAME > FROM TABLE NAME
Suppose
there is a table named employees and in that table there is a table named
salary and in that table we need to display the average salary of the employees
in the table so we need to enter the average command as –
SELECT
AVG SALARY FROM EMPLOYEES ;
that's
all about today's topic. thank you for visiting
IN
THE NEXT BLOG WE LEARN MORE ABOUT THE ALIASES AND THE SQL FUNCTIONS IN THE SQL
AND OTHER COMMANDS AND THE OTHER WORKING IN PYTHON AND OTHER IMPORTANT SUB
TOPICS. THANK YOU FOR VISITING , KEEP LEARNING STAY TUNED FOR NEXT BLOG ,
FOLLOW OUR BLOG FOR REGULAR UPDATES , VIEW OUR PREVIOUS BLOG FOR THE BASIC
CONCEPTS OF PYTHON AND OTHER BASIC CONCEPTS OF COMPUTER AND ALSO FOR THE
IMPORTANT DEFINITIONS OF THE SQL , VISIT OUR SECOND BLOG –
customercarereport.blogspot.com , VISIT OUR THIRD BLOG –
top23things.blogspot.com , VISIT OUR YOUTUBE CHANNEL - Learn Python Our YouTube channel will give
you the short motivational speeches of the great person in the present there is
only seven motivational videos on channel but in future I will upload the
motivational videos soon .VISIT OUR INSTAGRAM PAGE –
instagram.com/learnpython16, Our Instagram page is also a new page i just created
few days ago but stay tuned I will upload the post very soon. Please support us
by following our blog and by subscribing our YouTube channel and by following
our Instagram page.
Aggregate Functions
Reviewed by Learn Python
on
January 01, 2020
Rating:

No comments: