How to compute the sum of multiple columns in PostgreSQL
postgresql
Solution
SELECT COALESCE(col1,0) + COALESCE(col2,0)
FROM yourtable
Problem
I would like to know if there's a way to compute the sum of multiple columns in PostgreSQL. I have a table with more than 80 columns and I have to write a query that adds each value from each column. I tried with SUM(col1, col2, col3 etc) but it didn't work.