SQL ISNULL Function



  SQL > Advanced SQL > ISNULL Function

The ISNULL function is available in both SQL Server and MySQL. However, their uses are different:

SQL Server

In SQL Server, the ISNULL( ) function is used to replace NULL value with another value.

For example, if we have the following table,

Table Sales_Data
store_nameSales
Store A300
Store BNULL

The following SQL,

SELECT SUM(ISNULL(Sales,100)) FROM Sales_Data;

returns 400. This is because NULL has been replaced by 100 via the ISNULL function.

MySQL

In MySQL, the ISNULL( ) function is used to test whether an expression is NULL. If the expression is NULL, this function returns 1. Otherwise, this function returns 0.

For example,

ISNULL(3*3) returns 0

ISNULL(3/0) returns 1

Next: SQL IFNULL Function




Copyright © 2013 1keydata.com   All Rights Reserved.     Privacy Policy


SQL UNION
SQL UNION ALL
SQL Inline View
SQL INTERSECT
SQL MINUS
SQL LIMIT
SQL TOP
SQL Subquery
SQL EXISTS
SQL CASE
SQL DECODE
SQL AUTO INCREMENT
SQL IDENTITY
SQL SEQUENCE And NEXTVAL
SQL NULL
SQL ISNULL
SQL IFNULL
SQL NVL
SQL COALESCE
SQL NULLIF
SQL Rank
SQL Median
SQL Running Totals
SQL Percent to Total
SQL Cumulative Percent to Total


SQL Video Tutorial
SQL Jobs




Site Map
Resources