Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You're right about division by zero. From SQL92:

         4) The dyadic arithmetic operators <plus sign>, <minus sign>, <as-
            terisk>, and <solidus> (+, -, *, and /, respectively) specify
            addition, subtraction, multiplication, and division, respec-
            tively. If the value of a divisor is zero, then an exception
            condition is raised: data exception-division by zero.
However, the "any operation involving NULL yields NULL" is standard:

         1) If the value of any <numeric primary> simply contained in a
            <numeric value expression> is the null value, then the result of
            the <numeric value expression> is the null value.
https://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt

So, dividing by NULL is allowed and yields NULL. Dividing by zero yielding NULL is non-standard (I used it though).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: