mercredi 8 avril 2015

Add values in a row, substituing 0 for NULL

I have a table that looks like this:



ID | VALUE A | VALUE B
----------------------
1 | 20 | NULL
2 | NULL | 100
3 | NULL | NULL
4 | 100 | 50


I want to run a query (Sqlite) that returns the ID and the sum of VALUE A and VALUE B (NULL should be zero). The result should look like:



ID | SCORE
----------
1 | 20
2 | 100
3 | 0
4 | 150

Aucun commentaire:

Enregistrer un commentaire