SUM( null) != null + 0

SQlite online

  • sum(X) filter null
  • null + X => gives null
select sum(val), count(*)
from ( select 1 + null as val, 1 as row
union
select 4 as val, 1 as row
) t
group by row
Written on February 25, 2019, Last update on February 25, 2019
sql online null