Suppose I have a table my_table that has the following structure:
id::int counts::array
--------------------
02 {0,0,0,0,0,0,0}
03 {10,0,0,20,40,10,0}
04 {0,0,0,0,0,0,0}
05 {0,20,30,20,0,10,10}
06 {0,0,0,27,0,50,4}
07 {1,0,0,0,0,0,0}
08 {0,0,0,0,0,0,0}
I would like to run the following query, presented in pseudo code:
SELECT id, counts FROM my_table
WHERE NOT SUM(ARRAY_TO_STRING(counts, ', ')::int) = 0
I know I cannot use aggregate functions in a where clause, but what would be the quickest way to do this in PSQL?