In psuedo-code, this is bascially what I would like to do:
select
if a1 >= 0 and a1 <= 2
a2 + a7 + a8 as sum
else
a2 + a8 as sum
from table_name
;
(The column names, etc. are just for illustration.)
In English: I need to sum different columns for each of a few thousand records. I'd like to do the sum in SQL, if possible. There are only one or two differences between the conditions, either a single column missing/added, a substitution, or both. This is based on the business logic of the application, not a design decision of my choice.
I'm using sqlite3 (3.6.10), which limits the options somewhat.