Aggregate Functions In MySQL Flashcards
What are aggregate functions in MySQL used for?
To perform calculations on a set of values and return a single value as a result
What does the COUNT() function do?
Counts the number of rows that meet a specified condition
What is the syntax for the COUNT() function?
COUNT(column_name)
or COUNT(*)
Provide an example of using COUNT() in SQL.
SELECT COUNT(*) FROM customers
What does the SUM() function calculate?
The sum of values in a specified column
What is the syntax for the SUM() function?
SUM(column_name)
Provide an example of using SUM() in SQL.
SELECT SUM(amount) FROM orders
What does the AVG() function calculate?
The average value of a specified column
What is the syntax for the AVG() function?
AVG(column_name)
Provide an example of using AVG() in SQL.
SELECT AVG(price) FROM products
What does the MIN() function return?
The minimum value of a specified column
What is the syntax for the MIN() function?
MIN(column_name)
Provide an example of using MIN() in SQL.
SELECT MIN(order_date) FROM orders
What does the MAX() function return?
The maximum value of a specified column
What is the syntax for the MAX() function?
MAX(column_name)