In SQL queries, NULL behaves differently when using certain functions, e.g.:
A table with:
| ID | Cliente | Valor Gasto |
| 01 | JOAO | 100 |
| 02 | PEDRO | NULL |
| 03 | MARIA | 50 |
When executing
SELECT SUM(Valor_Gasto) * 100 / COUNT(ID) FROM tabela
SELECT SUM(Valor_Gasto) * 100 / COUNT(Valor_Gasto) FROM tabela
In the first query COUNT is equal to 3 and you receive the value 50, in the second COUNT is equal to 2 and you receive 75, because null is ignored in the count.
Nothing much, but depending on how you want to calculate, this avoids using a validation in WHERE.
Or when you validate with <> (other than) or IS NOT, ex:
SELECT Cliente FROM tabela WHERE Valor_Gasto <> 50
This would bring feathers Joao, because Pedro has value NULL, would have to treat the column or use a function that considers null, I do not know for all languages but in Postgres can use:
SELECT Cliente FROM tabela WHERE Valor_Gasto IS DISTINCT FROM 50
OR (this think is universal)
SELECT Cliente FROM tabela WHERE COALESCE(Valor_Gasto,0) <> 50
In the above query it exchanges NULL for 0, then the Spent Value will never be NULL, I hope to have helped somehow