NULL Handling — Concept Check
Questions on NULL Handling. NULL represents the absence of a value; SQL uses three-valued logic (TRUE/FALSE/UNKNOWN), so NULL comparisons require IS NULL/IS NOT NULL and functions like COALESCE and NULLIF.
Questions in this quiz
8 questions on NULL Handling — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.In an SQL query, what will be the result of the expression `NULL = NULL`?
- ANULL
- BUNKNOWN
- CFALSE
- DTRUE
2.A developer writes a query using `WHERE salary = NULL` to find employees with no salary. What will be the result?
- AIt will return all rows
- BIt will return no rows
- CIt will return all rows with NULL salary
- DIt will return rows with salary 0
3.Which SQL function would you use to handle potential NULL values when calculating averages?
- ACOUNT
- BCOALESCE
- CNULLIF
- DIS NULL
4.In a query, how does `COUNT(column_name)` differ from `COUNT(*)`?
- A`COUNT(column_name)` counts all rows
- B`COUNT(*)` ignores NULLs
- C`COUNT(*)` counts only non-NULLs
- D`COUNT(column_name)` ignores NULLs
5.A report shows NULL values as '-1' for sorting. Which SQL function helps achieve this?
- AIFNULL
- BCOALESCE
- CIS NULL
- DNULLIF
6.What happens when you use `SUM(column_name)` on a column with NULL values?
- ANULLs are treated as 0
- BNULLs cause an error
- CNULLs are ignored and not counted
- DNULLs are included in the sum
7.Why might `NULLIF` be used in a division operation in SQL?
- ATo handle all NULL values
- BTo replace NULL with zero
- CTo ensure non-zero results
- DTo prevent division by zero
8.A developer mistakenly believes `NULL != 5` evaluates to TRUE. What is the actual result?
- ATRUE
- BFALSE
- CUNKNOWN
- DNULL