<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – NULL-handling functions</title>
    <link>/en/sql-reference/functions/null-handling-functions/</link>
    <description>Recent content in NULL-handling functions on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/sql-reference/functions/null-handling-functions/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Sql-Reference: COALESCE</title>
      <link>/en/sql-reference/functions/null-handling-functions/coalesce/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/coalesce/</guid>
      <description>
        
        
        &lt;p&gt;Returns the value of the first non-null expression in the list. If all expressions evaluate to null, then &lt;code&gt;COALESCE&lt;/code&gt; returns null.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;COALESCE&lt;/code&gt; conforms to the ANSI SQL-92 standard.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;COALESCE ( { * | &lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;[,...] } )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;* | &lt;/code&gt;&lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt;&lt;code&gt;[,...]&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;One of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;*&lt;/code&gt; (asterisk)&lt;/p&gt;
&lt;p&gt;Evaluates all columns in the queried table.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;An expression of any data type. Functions that are included in &lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt; must be deterministic.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;COALESCE returns the first non-null value in each row that is queried from table &lt;code&gt;lead_vocalists&lt;/code&gt;. Note that in the first row, COALESCE returns an empty string.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT quote_nullable(fname)fname, quote_nullable(lname)lname,
     quote_nullable(coalesce (fname, lname)) &amp;#34;1st non-null value&amp;#34; FROM lead_vocalists ORDER BY fname;
  fname  |   lname   | 1st non-null value
---------+-----------+--------------------
 &amp;#39;&amp;#39;      | &amp;#39;Sting&amp;#39;   | &amp;#39;&amp;#39;
 &amp;#39;Diana&amp;#39; | &amp;#39;Ross&amp;#39;    | &amp;#39;Diana&amp;#39;
 &amp;#39;Grace&amp;#39; | &amp;#39;Slick&amp;#39;   | &amp;#39;Grace&amp;#39;
 &amp;#39;Mick&amp;#39;  | &amp;#39;Jagger&amp;#39;  | &amp;#39;Mick&amp;#39;
 &amp;#39;Steve&amp;#39; | &amp;#39;Winwood&amp;#39; | &amp;#39;Steve&amp;#39;
 NULL    | &amp;#39;Cher&amp;#39;    | &amp;#39;Cher&amp;#39;
(6 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/language-elements/expressions/case-expressions/#&#34;&gt;CASE expressions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/isnull/#&#34;&gt;ISNULL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: IFNULL</title>
      <link>/en/sql-reference/functions/null-handling-functions/ifnull/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/ifnull/</guid>
      <description>
        
        
        &lt;p&gt;Returns the value of the first non-null expression in the list.&lt;/p&gt;
&lt;p&gt;IFNULL is an alias of &lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/nvl/#&#34;&gt;NVL&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;IFNULL ( &lt;span class=&#34;code-variable&#34;&gt;expression1&lt;/span&gt; , &lt;span class=&#34;code-variable&#34;&gt;expression2&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If *&lt;code&gt;expression1 &lt;/code&gt;*is null, then IFNULL returns &lt;em&gt;&lt;code&gt;expression2. &lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If *&lt;code&gt;expression1 &lt;/code&gt;*is not null, then IFNULL returns &lt;em&gt;&lt;code&gt;expression1. &lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt; is the more standard, more general function.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;IFNULL is equivalent to ISNULL.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;IFNULL is equivalent to COALESCE except that IFNULL is called with only two arguments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;ISNULL(a,b)&lt;/code&gt; is different from &lt;code&gt;x IS NULL&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The arguments can have any data type supported by OpenText™ Analytics Database.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implementation is equivalent to the CASE expression. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CASE WHEN expression1 IS NULL THEN expression2
ELSE expression1 END;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The following statement returns the value 140:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT IFNULL(NULL, 140) FROM employee_dimension;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The following statement returns the value 60:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT IFNULL(60, 90) FROM employee_dimension;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT IFNULL (SCORE, 0.0) FROM TESTING;
 IFNULL
--------
  100.0
   87.0
     .0
     .0
     .0
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/language-elements/expressions/case-expressions/#&#34;&gt;CASE expressions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/nvl/#&#34;&gt;NVL&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/isnull/#&#34;&gt;ISNULL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: ISNULL</title>
      <link>/en/sql-reference/functions/null-handling-functions/isnull/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/isnull/</guid>
      <description>
        
        
        &lt;p&gt;Returns the value of the first non-null expression in the list.&lt;/p&gt;
&lt;p&gt;ISNULL is an alias of &lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/nvl/#&#34;&gt;NVL&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ISNULL ( &lt;span class=&#34;code-variable&#34;&gt;expression1&lt;/span&gt; , &lt;span class=&#34;code-variable&#34;&gt;expression2&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If *&lt;code&gt;expression1 &lt;/code&gt;*is null, then ISNULL returns &lt;em&gt;&lt;code&gt;expression2. &lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If *&lt;code&gt;expression1 &lt;/code&gt;*is not null, then ISNULL returns &lt;em&gt;&lt;code&gt;expression1. &lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt; is the more standard, more general function.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;ISNULL is equivalent to COALESCE except that ISNULL is called with only two arguments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;ISNULL(a,b)&lt;/code&gt; is different from &lt;code&gt;x IS NULL&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The arguments can have any data type supported by OpenText™ Analytics Database.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implementation is equivalent to the CASE expression. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CASE WHEN expression1 IS NULL THEN expression2
ELSE expression1 END;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The following statement returns the value 140:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT ISNULL(NULL, 140) FROM employee_dimension;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The following statement returns the value 60:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT ISNULL(60, 90) FROM employee_dimension;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT product_description, product_price,
ISNULL(product_cost, 0.0) AS cost
FROM product_dimension;
      product_description       | product_price | cost
--------------------------------+---------------+------
 Brand #59957 wheat bread       |           405 |  207
 Brand #59052 blueberry muffins |           211 |  140
 Brand #59004 english muffins   |           399 |  240
 Brand #53222 wheat bread       |           323 |   94
 Brand #52951 croissants        |           367 |  121
 Brand #50658 croissants        |           100 |   94
 Brand #49398 white bread       |           318 |   25
 Brand #46099 wheat bread       |           242 |    3
 Brand #45283 wheat bread       |           111 |  105
 Brand #43503 jelly donuts      |           259 |   19
(10 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/language-elements/expressions/case-expressions/#&#34;&gt;CASE expressions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/nvl/#&#34;&gt;NVL&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: NULLIF</title>
      <link>/en/sql-reference/functions/null-handling-functions/nullif/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/nullif/</guid>
      <description>
        
        
        &lt;p&gt;Compares two expressions. If the expressions are not equal, the function returns the first expression (expression1). If the expressions are equal, the function returns null.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NULLIF( &lt;span class=&#34;code-variable&#34;&gt;expression1, expression2 &lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;&lt;span class=&#34;code-variable&#34;&gt;expression1&lt;/span&gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Is a value of any data type.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;&lt;span class=&#34;code-variable&#34;&gt;expression2&lt;/span&gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Must have the same data type as *&lt;code&gt;expr1 &lt;/code&gt;*or a type that can be implicitly cast to match &lt;em&gt;&lt;code&gt;expression1&lt;/code&gt;&lt;/em&gt;. The result has the same type as &lt;em&gt;&lt;code&gt;expression1&lt;/code&gt;&lt;/em&gt;.&lt;/dd&gt;
&lt;/dl&gt;

&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following series of statements illustrates one simple use of the NULLIF function.&lt;/p&gt;
&lt;p&gt;Creates a single-column table &lt;code&gt;t and insert some values&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE TABLE t (x TIMESTAMPTZ);
INSERT INTO t VALUES(&amp;#39;2009-09-04 09:14:00-04&amp;#39;);
INSERT INTO t VALUES(&amp;#39;2010-09-04 09:14:00-04&amp;#39;);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Issue a select statement:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT x, NULLIF(x, &amp;#39;2009-09-04 09:14:00 EDT&amp;#39;) FROM t;
           x            |         nullif
------------------------+------------------------
 2009-09-04 09:14:00-04 |
 2010-09-04 09:14:00-04 | 2010-09-04 09:14:00-04
SELECT NULLIF(1, 2);
 NULLIF
--------
      1
(1 row)
SELECT NULLIF(1, 1);
 NULLIF
--------
(1 row)
SELECT NULLIF(20.45, 50.80);
 NULLIF
--------
  20.45
(1 row)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: NULLIFZERO</title>
      <link>/en/sql-reference/functions/null-handling-functions/nullifzero/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/nullifzero/</guid>
      <description>
        
        
        &lt;p&gt;Evaluates to NULL if the value in the column is 0.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NULLIFZERO(&lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;&lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;(INTEGER, DOUBLE PRECISION, INTERVAL, or NUMERIC) Is the string to evaluate for 0 values.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The TESTING table below shows the test scores for 5 students. Note that test scores are missing for S. Robinson and K. Johnson (NULL values appear in the Score column.)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM TESTING;
    Name     | Score
-------------+-------
 J. Doe      |   100
 R. Smith    |    87
 L. White    |     0
 S. Robinson |
 K. Johnson  |
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The SELECT statement below specifies that OpenText™ Analytics Database should return any 0 values in the Score column as Null. In the results, you can see that the database returns L. White&#39;s 0 score as Null.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT Name, NULLIFZERO(Score) FROM TESTING;
    Name     | NULLIFZERO
-------------+------------
 J. Doe      |        100
 R. Smith    |         87
 L. White    |
 S. Robinson |
 K. Johnson  |
(5 rows)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Sql-Reference: NVL</title>
      <link>/en/sql-reference/functions/null-handling-functions/nvl/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/nvl/</guid>
      <description>
        
        
        &lt;p&gt;Returns the value of the first non-null expression in the list.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NVL ( &lt;span class=&#34;code-variable&#34;&gt;expression1&lt;/span&gt; , &lt;span class=&#34;code-variable&#34;&gt;expression2&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If *&lt;code&gt;expression1 &lt;/code&gt;*is null, then NVL returns &lt;em&gt;&lt;code&gt;expression2. &lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If *&lt;code&gt;expression1 &lt;/code&gt;*is not null, then NVL returns &lt;em&gt;&lt;code&gt;expression1. &lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt; is the more standard, more general function.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;NVL is equivalent to COALESCE except that NVL is called with only two arguments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The arguments can have any data type supported by OpenText™ Analytics Database.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Implementation is equivalent to the CASE expression:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CASE WHEN &lt;span class=&#34;code-variable&#34;&gt;expression1 &lt;/span&gt;IS NULL THEN &lt;span class=&#34;code-variable&#34;&gt;expression2
    &lt;/span&gt;ELSE &lt;span class=&#34;code-variable&#34;&gt;expression1 &lt;/span&gt;END;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;expression1 is not null, so NVL returns expression1:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT NVL(&amp;#39;fast&amp;#39;, &amp;#39;database&amp;#39;);
nvl
------
 fast
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;expression1 is null, so NVL returns expression2:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT NVL(null, &amp;#39;database&amp;#39;);
nvl
----------
 database
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;expression2 is null, so NVL returns expression1:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT NVL(&amp;#39;fast&amp;#39;, null);
nvl
------
 fast
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the following example, expression1 (title) contains nulls, so NVL returns expression2 and substitutes &#39;Withheld&#39; for the unknown values:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT customer_name, NVL(title, &amp;#39;Withheld&amp;#39;) as title
FROM customer_dimension
ORDER BY title;
     customer_name      | title
------------------------+-------
 Alexander I. Lang      | Dr.
 Steve S. Harris        | Dr.
 Daniel R. King         | Dr.
 Luigi I. Sanchez       | Dr.
 Duncan U. Carcetti     | Dr.
 Meghan K. Li           | Dr.
 Laura B. Perkins       | Dr.
 Samantha V. Robinson   | Dr.
 Joseph P. Wilson       | Mr.
 Kevin R. Miller        | Mr.
 Lauren D. Nguyen       | Mrs.
 Emily E. Goldberg      | Mrs.
 Darlene K. Harris      | Ms.
 Meghan J. Farmer       | Ms.
 Bettercare             | Withheld
 Ameristar              | Withheld
 Initech                | Withheld
(17 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/language-elements/expressions/case-expressions/#&#34;&gt;CASE expressions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/isnull/#&#34;&gt;ISNULL&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/nvl2/#&#34;&gt;NVL2&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: NVL2</title>
      <link>/en/sql-reference/functions/null-handling-functions/nvl2/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/nvl2/</guid>
      <description>
        
        
        &lt;p&gt;Takes three arguments. If the first argument is not NULL, it returns the second argument, otherwise it returns the third argument. The data types of the second and third arguments are implicitly cast to a common type if they don&#39;t agree, similar to &lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;behavior-type&#34;&gt;Behavior type&lt;/h2&gt;
&lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/immutable-invariant-functions/&#34; title=&#34;&#34;&gt;Immutable&lt;/a&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NVL2 ( &lt;span class=&#34;code-variable&#34;&gt;expression1&lt;/span&gt; , &lt;span class=&#34;code-variable&#34;&gt;expression2&lt;/span&gt; , &lt;span class=&#34;code-variable&#34;&gt;expression3&lt;/span&gt; );
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;expression1&lt;/code&gt;&lt;/em&gt; is not null, then NVL2 returns &lt;em&gt;&lt;code&gt;expression2&lt;/code&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If &lt;em&gt;&lt;code&gt;expression1&lt;/code&gt;&lt;/em&gt; is null, then NVL2 returns &lt;em&gt;&lt;code&gt;expression3&lt;/code&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;p&gt;Arguments two and three can have any data type supported by OpenText™ Analytics Database.&lt;/p&gt;
&lt;p&gt;Implementation is equivalent to the CASE expression:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;CASE WHEN&lt;/code&gt; &lt;em&gt;&lt;code&gt;expression1&lt;/code&gt;&lt;/em&gt; &lt;code&gt;IS NOT NULL THEN&lt;/code&gt; &lt;em&gt;&lt;code&gt;expression2&lt;/code&gt;&lt;/em&gt; &lt;code&gt;ELSE&lt;/code&gt; &lt;em&gt;&lt;code&gt;expression3&lt;/code&gt;&lt;/em&gt; &lt;code&gt;END;&lt;/code&gt;&lt;/p&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;In this example, expression1 is not null, so NVL2 returns expression2:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT NVL2(&amp;#39;very&amp;#39;, &amp;#39;fast&amp;#39;, &amp;#39;database&amp;#39;);
nvl2
------
 fast
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this example, expression1 is null, so NVL2 returns expression3:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT NVL2(null, &amp;#39;fast&amp;#39;, &amp;#39;database&amp;#39;);
nvl2
----------
 database
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the following example, expression1 (title) contains nulls, so NVL2 returns expression3 (&#39;Withheld&#39;) and also substitutes the non-null values with the expression &#39;Known&#39;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT customer_name, NVL2(title, &amp;#39;Known&amp;#39;, &amp;#39;Withheld&amp;#39;)
as title
FROM customer_dimension
ORDER BY title;
     customer_name      | title
------------------------+-------
 Alexander I. Lang      | Known
 Steve S. Harris        | Known
 Daniel R. King         | Known
 Luigi I. Sanchez       | Known
 Duncan U. Carcetti     | Known
 Meghan K. Li           | Known
 Laura B. Perkins       | Known
 Samantha V. Robinson   | Known
 Joseph P. Wilson       | Known
 Kevin R. Miller        | Known
 Lauren D. Nguyen       | Known
 Emily E. Goldberg      | Known
 Darlene K. Harris      | Known
 Meghan J. Farmer       | Known
 Bettercare             | Withheld
 Ameristar              | Withheld
 Initech                | Withheld
(17 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/language-elements/expressions/case-expressions/#&#34;&gt;CASE expressions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/null-handling-functions/coalesce/#&#34;&gt;COALESCE&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: ZEROIFNULL</title>
      <link>/en/sql-reference/functions/null-handling-functions/zeroifnull/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/functions/null-handling-functions/zeroifnull/</guid>
      <description>
        
        
        &lt;p&gt;Evaluates to 0 if the column is NULL.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ZEROIFNULL(&lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;String to evaluate for NULL values, one of the following data types:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;INTEGER&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DOUBLE PRECISION&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;INTERVAL&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;NUMERIC&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following query returns scores for five students from table &lt;code&gt;test_results&lt;/code&gt;, where &lt;code&gt;Score&lt;/code&gt; is set to 0 for L. White, and null for S. Robinson and K. Johnson:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT Name, Score FROM test_results;
    Name     | Score
-------------+-------
 J. Doe      |   100
 R. Smith    |    87
 L. White    |     0
 S. Robinson |
 K. Johnson  |
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The next query invokes ZEROIFNULL on column &lt;code&gt;Score&lt;/code&gt;, so OpenText™ Analytics Database returns 0 for for S. Robinson and K. Johnson:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT Name, ZEROIFNULL (Score) FROM test_results;
    Name     | ZEROIFNULL
-------------+------------
 J. Doe      |        100
 R. Smith    |         87
 L. White    |          0
 S. Robinson |          0
 K. Johnson  |          0
(5 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can also use ZEROIFNULL in &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-table/partition-clause/&#34;&gt;&lt;code&gt;PARTITION BY&lt;/code&gt; expressions&lt;/a&gt;, which must always resolve to a non-null value. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE TABLE t1 (a int, b int) PARTITION BY (ZEROIFNULL(a));
CREATE TABLE
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The database invokes this function when it partitions table &lt;code&gt;t1&lt;/code&gt;, typically during a load operation. During the load, the function checks the data of the &lt;code&gt;PARTITION BY&lt;/code&gt; expression—in this case, column &lt;code&gt;a&lt;/code&gt;—for null values. If encounters a null value in a given row, it sets the partition key to 0, instead of returning with an error.&lt;/p&gt;

      </description>
    </item>
    
  </channel>
</rss>
