LNNVL

LNNVL is a function in SQL that provides a logical result from a comparison operation involving nulls. It takes a condition as an argument, and returns true if the condition is false or unknown, and false if the condition is true. This is useful in scenarios where null-handling is critical.

LNNVL(condition)

  • condition: This parameter represents the condition to be evaluated by the `LNNVL` function. It includes an expression or a comparison between expressions that yields a Boolean value. When the `condition` parameter evaluates as FALSE, ‘LNNVL(condition)’ returns TRUE. Conversely, if `condition` evaluates to TRUE or UNKNOWN, `LNNVL(condition)` returns FALSE. This function is typically used in SQL queries involving NULL values.

Example

SELECT LAST_NAME, SALARY,
LNNVL(COMMISSION_PCT IS NULL)
FROM EMPLOYEES;

Output

| LAST_NAME | SALARY | LNNVL(COMMISSION_PCT IS NULL) |
| -------------- | ---------- | ------------------------------- |
| King | 24000 | 0 |
| Kochhar | 17000 | 0 |
| De Haan | 17000 | 0 |
| Hunold |9000 | 1 |

Explanation

The LNNVL function is a conditional function in Oracle SQL that returns true if the condition is false or unknown (NULL), and false if the condition is true. It is used for handling NULL values.

In the example, the function LNNVL(COMMISSION_PCT IS NULL) will return 0 for employees with known commission percentages (where the condition is false), and 1 for employees with unknown (NULL) commission percentages (where the condition is true).

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.