0
0
PostgreSQLquery~5 mins

COUNT, SUM, AVG, MIN, MAX in PostgreSQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the COUNT() function do in SQL?
COUNT() returns the number of rows that match a specified condition or all rows if no condition is given.
Click to reveal answer
beginner
How does the SUM() function work in SQL?
SUM() adds up all the values in a numeric column and returns the total sum.
Click to reveal answer
beginner
What is the purpose of the AVG() function?
AVG() calculates the average (mean) value of a numeric column by adding all values and dividing by the count.
Click to reveal answer
beginner
Explain what MIN() and MAX() functions do.
MIN() returns the smallest value in a column, and MAX() returns the largest value in a column.
Click to reveal answer
intermediate
Can aggregate functions like COUNT(), SUM(), AVG(), MIN(), MAX() be used without GROUP BY?
Yes, they can be used without GROUP BY to calculate values over the entire table or filtered rows.
Click to reveal answer
Which SQL function counts the number of rows in a table?
AAVG()
BSUM()
CCOUNT()
DMAX()
What does SUM(salary) return in a table of employees?
AThe total sum of all salaries
BThe average salary
CThe highest salary
DThe total number of employees
Which function would you use to find the smallest value in a column?
AMAX()
BAVG()
CCOUNT()
DMIN()
If you want the average price of products, which function is correct?
AAVG(price)
BSUM(price)
CCOUNT(price)
DMAX(price)
Can you use aggregate functions without GROUP BY to get a single summary value?
ANo, GROUP BY is always required
BYes, it returns a summary for the whole table
COnly COUNT() can be used without GROUP BY
DOnly SUM() and AVG() can be used without GROUP BY
Describe how COUNT(), SUM(), AVG(), MIN(), and MAX() functions work in SQL.
Think about what each function returns when applied to a column.
You got /5 concepts.
    Explain when you would use aggregate functions with and without GROUP BY.
    Consider how grouping changes the output of aggregate functions.
    You got /3 concepts.