Which function counts the number of rows in a result set?

Prepare for the IGCSE Algorithms and Pseudocode Exam. Study with comprehensive questions covering key algorithms and pseudocode techniques. Access hints and explanations to gear up for your exam success!

Multiple Choice

Which function counts the number of rows in a result set?

Explanation:
Counting how many rows are produced by a query is done with the COUNT function. It returns a numeric value representing the number of rows in the result set. For example, SELECT COUNT(*) FROM employees WHERE status = 'active' counts every row that matches the condition, giving the total number of active employees. The asterisk means counting all rows, regardless of NULLs. If you use COUNT(column), you count only rows where that particular column has a non-NULL value, which is a nuance to be aware of. The other functions do different things: SUM adds up numeric values in a column across the rows, MAX returns the largest value in a column, and MIN returns the smallest. None of these give the total number of rows in the result. So COUNT is the correct choice for counting rows in a result set.

Counting how many rows are produced by a query is done with the COUNT function. It returns a numeric value representing the number of rows in the result set. For example, SELECT COUNT(*) FROM employees WHERE status = 'active' counts every row that matches the condition, giving the total number of active employees. The asterisk means counting all rows, regardless of NULLs. If you use COUNT(column), you count only rows where that particular column has a non-NULL value, which is a nuance to be aware of.

The other functions do different things: SUM adds up numeric values in a column across the rows, MAX returns the largest value in a column, and MIN returns the smallest. None of these give the total number of rows in the result. So COUNT is the correct choice for counting rows in a result set.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy