I can remove easily the first element from an array:
SELECT (ARRAY[1,2,3])[2:]
--{2,3}
What is the simplest way to remove the last element as well ?
The size is dynamic and is not known at compile time.
I can remove easily the first element from an array:
SELECT (ARRAY[1,2,3])[2:]
--{2,3}
What is the simplest way to remove the last element as well ?
The size is dynamic and is not known at compile time.
2
Answers
You can use the array length function to get the array length:
trim_array() is there since PostgreSQL 14: