DATA-MANAGEMENT-FOUNDATIONS practice question 15 of 15

What does the aggregate function do?

Full set: 60 questions

Domain Data Querying

Answer options
A: It computes values over a set of rows. Correct answer
B: It selects rows that appear in one table but not another.
C: It eliminates one or more columns of a table.
D: It lists combinations of rows in two tables.
Correct Answer:
A. It computes values over a set of rows.
Explanation

An aggregate function performs a calculation on a set of rows and returns a single, summary value. Common examples in SQL include COUNT(), SUM(), AVG(), MIN(), and MAX(). These functions are used to condense information from multiple rows into a single result, often in conjunction with the GROUP BY clause to create summary reports for different categories within the data. For instance, SUM(sales) would compute the total sales value across all rows in the specified group.

Why Incorrect

B. This describes a set difference operation, such as EXCEPT or MINUS, which is used to find distinct rows in one query result that are not present in another.
C. This describes projection, the process of selecting specific columns to be returned in a result set, which is the fundamental purpose of the SELECT clause itself.
D. This describes a JOIN operation (specifically a CROSS JOIN if no condition is specified), which is used to combine rows from two or more tables.

References

1. PostgreSQL 16 Documentation, Chapter 9: Functions and Operators, Section 9.21: Aggregate Functions. The documentation states, "Aggregate functions compute a single result from a set of input values." This directly supports the definition that they operate over a set of rows.

2. Oracle Database SQL Language Reference, 23c, Chapter 7: SQL Functions, "Aggregate Functions". The official documentation explains, "Aggregate functions return a single result row based on groups of rows, rather than on single rows." This confirms that their purpose is to compute a value over a set of rows.

3. Silberschatz, A., Korth, H. F., & Sudarshan, S. (2020). Database System Concepts (7th ed.). McGraw-Hill. Chapter 4, "Intermediate SQL", Section 4.1 "Aggregate Functions", p. 135. The text introduces aggregate functions by stating they "take a collection (a set or multiset) of values as input and return a single value."

Scroll to Top