I have a column box_coordinates of type integer[4] and I want to divide each element of the array by 640 and insert it into a new column of type float[4]. I first try to divide each element of the array before aggregating
SELECT n/640::float
FROM (
SELECT unnest(box_coordinates)
FROM images
) AS n;
but it fails with error
ERROR: operator does not exist: record / integer
HINT: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
How do I apply the array element division and then insert the result into a new column of type float[4], while keeping the order of the elements in the new array unchanged?