SQL Aggregate Function
1.Which of the following is an aggregate function?
-
A. LENGTH()
-
B. COUNT()
-
C. NOW()
-
D. COALESCE()
COUNT()
COUNT()
2.What does the SUM() function do?
-
A. Counts all values
-
B. Calculates total of numeric column
-
C. Sums characters
-
D. Returns average
Calculates total of numeric column
Calculates total of numeric column
3.Which statement returns the average salary?
SELECT _____ FROM employees;
-
A. AVG(salary)
-
B. AVERAGE(salary)
-
C. SUM(salary) / COUNT(*)
-
D. Both A and C
Both A and C
Both A and C
4.Do aggregate functions ignore NULL values?
-
A. Yes
-
B. No
-
C. Only MIN() does
-
D. Only COUNT(*) does
Yes
Yes
5.What will this query return?
SELECT COUNT(*) FROM students;
-
A. Count of NULL values
-
B. Count of rows excluding NULLs
-
C. Total number of rows including NULLs
-
D. 0
Total number of rows including NULLs
Total number of rows including NULLs