Q.In SQL, the aggregate function which will display the cardinality of the table is ____. (A) sum() (B) count() (C) avg() (D) sum()
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →The count(*) function returns the total number of rows in a table, which is its cardinality.
When we talk about the cardinality of a table in database terminology, we mean the number of rows (or tuples) it contains. It's a fundamental measure of the table's size — how many records exist in that relation. SQL provides a family of aggregate functions that perform calculations across multiple rows and return a single summary value, and understanding which one gives us cardinality is essential for querying databases effectively.
Aggregate functions operate on sets of values from a column (or columns) and collapse them into one result. The most common ones include:
sum()— adds up all the values in a numeric columnavg()— calculates the arithmetic mean of values in a numeric columncount()— counts rows or non-null valuesmax()andmin()— find the largest or smallest value
The question asks specifically which function reveals how many rows are in the table. The count(*) function does exactly this: it counts every row in the table, regardless of whether individual columns contain null values or not. The asterisk * tells SQL to count all rows without filtering by any particular column's content. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.