W3. SQL Aggregate Functions Flashcards
Q: What is an SQL Aggregate function?
A: A function that performs a calculation on a set of values and returns a single result.
Q: In SQL, with which clause are aggregate functions commonly used?
A: The GROUP BY clause.
Q: What does the GROUP BY clause do in SQL?
A: It splits the result set into groups, allowing aggregate functions to return a single value for each group.
Q: Name some commonly used SQL aggregate functions.
MIN() - smallest value
MAX() - largest value
COUNT() - number of rows
SUM() - total sum of a column
AVG() - average of a column
Q: What does the MIN() function do?
A: Returns the smallest value in a selected column.
Q: What does the MAX() function do?
A: Returns the largest value in a selected column.
Q: What does the COUNT() function do?
A: Returns the number of rows in a set, including NULL values.
Q: What does the SUM() function do?
A: Returns the total sum of a numerical column.
Q: What does the AVG() function do?
A: Returns the average value of a numerical column.
Q: Do aggregate functions ignore NULL values?
A: Yes, except for COUNT().