How to apply a function with arguments on every element in a text array in Postgresql SQL queries
Lets say My text array is
["abc-123-x", "def-123-y", "hij-234-k", "klm-232-p", "nop-3434-9", "qrs-23-p9"]
the result should be
[x,y,k,p,9,p9]
you need to unnest the array, extract the characters, then aggregate back:
select array_agg(right(t.w, 1))
from unnest(array['abc','def','hij','klm','nop','qrs']) as t(w);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.