Let's say I have a PostgreSQL table with 10 columns and 2 weeks (w1 w2) with 5 countries. Something that would look like this :
What I would like to do is a count per week and per column like this :
As count()
counts only the non-NULL values, this is a simple GROUP BY
query:
SELECT week, count(col1), ..., count(col10)
FROM your_table
GROUP BY week;
You can get through below query:
SELECT week,
SUM(Col1), SUM(Col2), SUM(Col3), SUM(Col4), SUM(Col5),
SUM(Col6), SUM(Col7), SUM(Col8), SUM(Col9), SUM(Col10)
FROM <table name>
GROUP BY 1