MYSQL Sum: How to excludes all instances either one of two other columns are null
You can do it with conditional aggregation:
SELECT customer_id,
SUM(CASE WHEN blocked IS NULL AND unapproved IS NULL THEN cost ELSE 0 END) total
FROM tablename
GROUP BY customer_id;
Or:
SELECT customer_id,
SUM(CASE WHEN COALESCE(locked, unapproved) IS NULL THEN cost ELSE 0 END) total
FROM tablename
GROUP BY customer_id;