**Sample Exam Questions**

S3.2 Functions and operators (Aggregate functions)

Choose one appropriate statement about the behavior when you execute:

SELECT count(*), count(x) FROM sample_table;

- Both count(*) and count(x) return the number of rows in the sample_table.
- count(*) returns the number of rows in sample_table, and count(x) returns the number of different types of values in column x.
- count(*) returns the number of rows in sample_table, and count(x) returns the number of rows where the value in column x is not NULL.
- count(*) returns the number of rows in sample_table where no column is NULL, and count(x) returns the number of rows where the value in column x is not NULL.
- count(*) returns the sum of the values in the leftmost column of sample_table, and count(x) returns the sum of the values in column x.

※This sample exam is different from those that appear in the actual OSS-DB Exam.

2024/05/01

Databases provide numerous functions to calculate statistical values such as the sum and average of data. Among these, 'count' is the most basic function used to count the number of data entries.

When you pass * as an argument, it simply returns the number of rows.

When you pass a column name or expression as an argument, it returns the number of rows where the value of that column or expression is not NULL.

**Therefore, the correct answer is C.**

It is important to note that NULL values are not only excluded from the count of data entries, but also from calculations such as averages.

There are more ways to execute the function than a simple SQL statement that queries the number of rows in a table, as in the example. If you add a WHERE clause, it returns the number of rows that satisfy the WHERE condition.

More typically, it is used with a GROUP BY clause to classify data based on the values in the specified columns and to investigate the number of rows in each group.

© EDUCO All Rights Reserved.