What value is returned after executing
the following statement?
Assume there are ten employee records and each contains a SALARY value of 100, except for one, which has a null value in the SALARY field. A. 900
--- Explanation: Answer A is correct, and the others are incorrect. Answer A explains that the SUM aggregate function ignores null values and adds non-null values. In this case, there are nine rows that contain the SALARY value of 100, and since null values are ignored, the sum of these values will be 900. Answer B is incorrect because it assumes that the NVL function is being used. NVL is a function in Oracle Database that returns a specified value if a null value is encountered. In this case, the function would return 100 for the one record with a null SALARY value, resulting in a sum of 1000 instead of the correct answer of 900. Answer C is incorrect because it assumes that regular arithmetic with null values returns a null result. While this is true for regular arithmetic, it's not true for aggregate functions like SUM. As mentioned earlier, SUM ignores null values, so the result will not be null. Answer D is incorrect because it assumes that the correct answer is not one of the options given. However, since answer A is correct, this option is also incorrect. To summarize, the correct answer is A because the SUM function ignores null values and adds the non-null values, resulting in a sum of 900. It's important to note that the behavior of null values in SQL can be tricky, and understanding how nulls are handled by different functions is essential to getting the correct results.
Oracle Books
Oracle Application
Oracle Home
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|