Save
Databases Final
Aggregate Functions
Save
Share
Learn
Content
Leaderboard
Learn
Created by
tiana okane
Visit profile
Cards (25)
Databases
A
structured
collection of data that is organized and stored in a way that allows for
efficient retrieval
, management, and manipulation of information
View source
Structured
Query Language (SQL)
A programming language used for managing data stored in
relational
databases
View source
Aggregate
Functions
MySQL built-in functions that perform a calculation on
multiple
values and return a
single
value
Essential for
database analysis
, enabling
quick
insights into large datasets and for reporting tasks
View source
Examples
of Aggregate Functions
total sales calculations
average
score in a class
Richest Man in
Northern Ireland
View source
Commonly
Used Aggregate Functions
COUNT() - returns the
number
of records
AVG() - computes the
average
of a set of values
SUM() -
adds
together all values in a
column
MIN() - returns the
smallest
value of the selected column
MAX() - returns the
largest
value of the selected column
View source
COUNT
()
The COUNT() function allows you to
count
all rows (COUNT(*)) or count only rows that match a specified condition (COUNT(column_name))
View source
The COUNT() function has forms like COUNT(*) FROM...,
COUNT
(*) FROM...WHERE...,
COUNT
(column_name) FROM..., COUNT(column_name) FROM...WHERE...
View source
SELECT
COUNT(*) FROM...
Counts the number of
rows
in a
table
View source
SELECT
COUNT(column_name) FROM...
Counts the number of
non-null
values in the specified
column
View source
Counting PetID or Name gives the
same
output count when filtering by
Type
= 'Cat'
View source
AVG
()
The
AVG()
function computes the
average
of a set of values
View source
Columns
in Pet table
PetID
Name
Type
Breed
Age
View source
SELECT
AVG
(column_name) FROM…
View source
SELECT AVG (Age) FROM
Pet
;
View source
SELECT
AVG (column_name) FROM…WHERE…
Calculates the average value of the specified column from the table, with an optional WHERE clause to filter the rows
View source
SELECT AVG (Age) FROM
Pet
WHERE TYPE =
'Dog'
;
View source
SELECT
SUM (column_name) FROM…
Calculates the
total sum
of the values in the specified
column
from the table
View source
SELECT
SUM (Age) FROM
Pet
;
View source
SELECT SUM
(column_name) FROM…WHERE…
Calculates the
total sum
of the values in the specified column from the table, with an optional WHERE clause to
filter
the rows
View source
SELECT
SUM (Age) FROM Pet WHERE TYPE =
'Dog'
;
View source
MAX
( )
Returns the maximum
value
in the specified column
View source
MIN
( )
Returns the
minimum
value in the specified column
View source
SELECT
MAX
(Age) FROM
Pet
;
View source
SELECT
MIN(Age)
FROM Pet;
View source
SELECT
Name, Age FROM Pet WHERE Age =(SELECT
MIN(Age)
FROM Pet);
View source