Null Value in the Salary Field

What value is returned after executing the following statement? 
(Choose the best answer.)

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
B. 1000
C. NULL
D. None of the above

---

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 Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.