{"id":60,"date":"2011-06-15T03:39:00","date_gmt":"2011-06-15T00:39:00","guid":{"rendered":"http:\/\/fatihacar.com\/blog\/?p=60"},"modified":"2013-07-03T08:57:57","modified_gmt":"2013-07-03T05:57:57","slug":"nvl-nvl2-coalesce-and-nullif-function-in-oracle","status":"publish","type":"post","link":"http:\/\/www.fatihacar.com\/blog\/nvl-nvl2-coalesce-and-nullif-function-in-oracle\/","title":{"rendered":"NVL, NVL2, COALESCE and NULLIF Function in Oracle"},"content":{"rendered":"<p>These functions work with any data type and pertain to the use of null values in the expression list. These functions use of null value and returns result value.<\/p>\n<p>NVL : Converts null value to an actual value.<br \/>\nNVL2 : If first expression is not null, return second expression. If first expression is null, return third expression. the first expression can have any data type.<br \/>\nCOALESCE : Return first not null expression in the expression list.<br \/>\nNULLIF : Compares two expressions and returns null if they are equal,returns the first expression if they are not equal.<\/p>\n<p>Example<\/p>\n<blockquote><p>Sample Table : employees<\/p>\n<table>\n<tr>\n<td>ID<\/td>\n<td>SALARY<\/td>\n<td>COMMISSION<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>10000<\/td>\n<td>0.05<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>8000<\/td>\n<td>null<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>5000<\/td>\n<td>0.1<\/td>\n<\/tr>\n<\/table>\n<p>select ID, SALARY, (NVL(COMMISSION,1)*SALARY)+SALARY as COM_SALARY from employees;<\/p>\n<p>Result :<\/p>\n<table>\n<tr>\n<td>ID<\/td>\n<td>SALARY<\/td>\n<td>COM_SALARY<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>10000<\/td>\n<td>10500<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>8000<\/td>\n<td>8000<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>5000<\/td>\n<td>5500<\/td>\n<\/tr>\n<\/table>\n<p>If you do not use NVL function, when COM_SALARY have a null value, print null. <\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>These functions work with any data type and pertain to the use of null values in the expression list. These functions use of null value and returns result value. NVL : Converts null value to an actual value. NVL2 : If first expression is not null, return second expression. If first expression is null, return&#8230;<\/p>\n","protected":false},"author":37,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-oracle-sql"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p39NFI-Y","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":9,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":799,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/60\/revisions\/799"}],"wp:attachment":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}