※This sample exam is different from those that appear in the actual OSS-DB Exam.
The NULL value used in a RDBMS is an extremely unique value and it should be used very carefully. For example, when arithmetic operations, such as addition and multiplication, are performed using an ordinary numerical value and NULL, the result will always be NULL. We can understand the difference by executing the following.
SELECT 2 + NULL; and SELECT 2 + 0;
The RDBMS includes aggregate functions for calculating the total value and average value of the column.
When executing these aggregate functions, NULL data will be ignored when the calculation is performed.
The count() function outputs the number of data items, and as the NULL data is ignored, count(val) will give 4 as the result.
However, count(*) is special in this case and even if all columns are null this will give the number of rows, so count(*) returns the answer as 5 .
The avg() function calculates the average value of the data. There are five rows of data in the sample1 table and four items of non-NULL data in the val column. As avg(val) calculates the average value of the four items of non-NULL data, it returns 2.5.
Therefore, the correct answer is C.