16.06.2010, 10:05
|
#1
|
Участник
|
East Ocean - Technical: SQL divide by zero "isZero" function
Источник: http://eastoceantechnical.blogspot.c...-function.html
==============
Recently come across a requirement on SQL to divide 2 columns and populate in a custom fields. Infact is just something simple like "SELECT column1/column2 AS result"
Issue raised because the "column2" might contains zero or null value, what we need to do is if column 2 is zero replace it with another fix non zero varible.
- Null issue can be easily solve by using isNull finction, but we don't have 'isZero' function
The solution is to use the nullif function with isnull function;
set column2 to null value if it is zero, outer level if is null replace with variable X.
ISNULL(NULLIF(column2, 0),variableX)
Источник: http://eastoceantechnical.blogspot.c...-function.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|
|