Let's say I'm trying to apply a division by 2 on an array
SELECT unnest(array[1.0, 2.0, 3.0])::REAL/2
This gives me three rows with the values 0.5, 1.0 and 1.5.
How do I then proceed to convert this back into an array? I tried
SELECT array_agg(unnest(array[1.0, 2.0, 3.0])::REAL/2)
But I get: ERROR: set-valued function called in context that cannot accept a set
Extra question: How would I go about the same problem, but on multi-dimensional arrays?
SELECT unnest(array[[1.0, 0.1], [2.0, 0.2]])::REAL/2
I would want an answer like "{{0.5,0.05},{1.0,0.1}}"