# Errors considered harmful

**URL:** <https://swi-prolog.discourse.group/t/errors-considered-harmful/3574>\
**Category:** Request For Comments\
**Created:** [February 8, 2021, 5:54pm UTC](https://swi-prolog.discourse.group/t/errors-considered-harmful/3574 "2021-02-08T17:54:43Z")\
**Posts on this page:** 1\
**Showing post:** 102

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [February 16, 2021, 12:30am UTC](https://swi-prolog.discourse.group/t/errors-considered-harmful/3574/102 "2021-02-16T00:30:57Z")

</div>

> [@anon95304481](#):
>
> Interestingly SQL has a better standing here. Since a) it has null values  
> and b) these are handled via [3-valued logic in SQL](https://modern-sql.com/de/konzept/dreiwertige-logik).

SQL also gets it wrong with NULLs.  
Consider a table with these values:

```prolog
   A B
   0 1
   1 null

```

then sum(A) + sum(B) = 2 but sum(A+B) = 1.

(And I have more examples of other problems with SQL’s null.)

For those who want to try this out (I used sqlite):

```prolog
create table t(a int, b int);
insert into t(a,b) values(0,1);
insert into t(a,b) values(1,null);
select sum(a)+sum(b), sum(a+b) from t;

```

---

_[View the full topic](https://swi-prolog.discourse.group/t/errors-considered-harmful/3574)._
