How to apply a function to each element of an array column in Postgres?

后端 未结 4 704
遇见更好的自我
遇见更好的自我 2020-12-07 20:32

A Pg query returns an array. I would like to retrieve that with each element formatted to 3 decimal places. How can I apply a function to each element of an array? Something

4条回答
  •  我在风中等你
    2020-12-07 21:06

    postgres=# select array(select round(unnest(array[1.2,2.4,3,4])));
       array   
    -----------
    {1,2,3,4}
    (1 row)
    

提交回复
热议问题