1Z0-909 · Question #63
Which two statements are true about aggregate functions?
The correct answer is E. AVG () does not allow use of the distinct option. Note: There appears to be an error in the provided answer key. Based on standard SQL behavior, E is actually false - AVG(DISTINCT column) is a valid and commonly supported syntax across Oracle, MySQL, PostgreSQL, and SQL Server. The two statements that are actually true are B…
Question
Which two statements are true about aggregate functions?
Options
- ASUM () returns o if there are no rows to aggregate.
- BMAX () returns null if there are no rows to aggregate.
- CCOUNT (distinct) returns a count of the number of rows with different values including Null.
- DMIN () cannot use distinct when it executes as a Windows function.
- EAVG () does not allow use of the distinct option.
How the community answered
(24 responses)- B4% (1)
- C8% (2)
- E88% (21)
Explanation
Note: There appears to be an error in the provided answer key. Based on standard SQL behavior, E is actually false - AVG(DISTINCT column) is a valid and commonly supported syntax across Oracle, MySQL, PostgreSQL, and SQL Server. The two statements that are actually true are B and D.
B is true: MAX() (and MIN(), SUM(), AVG()) return NULL - not zero - when there are no rows to aggregate. Only COUNT() returns 0 for an empty set.
D is true: Aggregate functions used as window functions (with an OVER clause) do not support the DISTINCT keyword. Attempting MIN(DISTINCT col) OVER (...) will produce an error.
Why the distractors are wrong:
- A is false -
SUM()returnsNULL, not0, on an empty set. - C is false -
COUNT(DISTINCT)excludesNULLvalues, just like plainDISTINCT. - E is false -
AVG(DISTINCT col)is valid SQL; it averages only the unique non-null values.
Memory tip: Think "NULLs on empty, no DISTINCT in windows." All aggregate functions return NULL when no rows qualify, and DISTINCT is never allowed inside a window function (OVER clause).
Topics
Community Discussion
No community discussion yet for this question.