Cellwise · SQL track
Calculations and missing values
Do maths in a query, and handle NULL.
You can calculate in SELECT, just like in a cell. One trap: in SQLite, an integer divided by an integer drops the fraction, so 7 / 2 is 3. Write 12.0 instead of 12 to keep the decimals.
NULL means “no value”. Any maths with NULL gives NULL, so COALESCE(value, 0) swaps a NULL for something you can use.
What you’ll do
- Work out monthly pay
- Replace missing values
- Work out each share