Return last value in of array (PostgreSQL 7.2.1)

Поиск
Список
Период
Сортировка
От Erwin Brandstetter
Тема Return last value in of array (PostgreSQL 7.2.1)
Дата
Msg-id Xns93FEE319E24A4BrandstetterFalterat@213.129.232.14
обсуждение исходный текст
Ответы Re: Return last value in of array (PostgreSQL 7.2.1)  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-admin
Hi Newsgroup!

I can't believe I have found a good solution here. I want to return the
last value of an array with an SQL statement, while I do not know, how many
items the array holds (u can never be sure of that since u can redim an
array in PostgreSQL whenever u like..).

That is what i came up with:


select my_array_field[substr(array_dims(my_array_field), 4, 1)]
from my_table;


But this only works, as long as the upper boundary is from 1 to 9 (one
digit). Besides it looks ugly and will perform likewise.

Did I miss something here?
Is there any function returning more sensible data than array_dims
(returning something like '[1:4]')?

Grateful for any hints.
Regards
Erwin Brandstetter

--
no z in my mail.

В списке pgsql-admin по дате отправления:

Предыдущее
От: "Nick Fankhauser - Doxpop"
Дата:
Сообщение: PG version for n_distinct question.
Следующее
От: Steve Crawford
Дата:
Сообщение: Re: Return last value in of array (PostgreSQL 7.2.1)