NULLIF
Returns NULL if the first argument is equal to the second argument, otherwise returns the first argument.
This function corresponds to the nullif(X, Y) function in SQLite. It compares its two arguments x and y. If they are equal, the function returns NULL. If they are not equal, it returns the value of the first argument, x.
The comparison uses SQLite's standard rules for equality. For string comparisons, it may be case-sensitive or case-insensitive depending on the column's collation sequence.
This function is useful for treating a specific value as NULL. For example, you might want to convert empty strings '' or a placeholder like 'N/A' into NULL in your query results.
Example
// Treat an empty string in the 'email' column as NULL.
// If email is '', NULLIF(email, '') returns NULL.
// If email is 'test@example.com', it returns 'test@example.com'.
val nullableEmail = select(NULLIF(Users.email, StringLiteral("")))
.from(Users)
// Consider a product price of 0.0 as NULL (e.g., if it means 'not priced yet').
val effectivePrice = select(NULLIF(Products.price, 0.0))
.from(Products)Return
A KQLiteColumn with the same type T as the input columns, containing the result of the NULLIF operation
Author
MOHAMMAD AZIM ANSARI
Parameters
The column or value to be returned if it is not equal to y.
The column or value to compare against x.
Type Parameters
The underlying data type of the first column.