PostgreSQL ISNULL
SQL Server supportsISNULL
function that replacesNULL
with a specified replacement value:
ISNULL(expression, replacement)
If theexpression
is NULL, then theISNULL
function returns thereplacement
. Otherwise, it returns the result of theexpression
.
PostgreSQL does not have theISNULL
function. However, you can use theCOALESCE
function which provides similar functionality.
Note that theCOALESCE
function returns the first non-null argument, so the following syntax has a similar effect as theISNULL
function above:
COALESCE(expression,replacement)
For theCOALESCE
example, check out theCOALESCE
function tutorial.
In addition toCOALESCE
function, you can use theCASE
expression:
SELECT CASE WHEN expression IS NULL THEN replacement ELSE expression END AS column_alias;
Check out theCASE
expression tutorial for more information.
Last updated on
Was this page helpful?
Thank you for your feedback!