returning an array as a list of single-column rows... (different approach)

Поиск
Список
Период
Сортировка
От
Тема returning an array as a list of single-column rows... (different approach)
Дата
Msg-id 001101c845b7$ee686590$cb3930b0$@de
обсуждение исходный текст
Ответ на Re: returning an array as a list fo single-column rows?  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Список pgsql-sql
An: pgsql-sql@postgresql.org
Betreff: Re: [SQL] returning an array as a list fo single-column rows?

The following will return the elements of an array each in its
Own row.  Using both array_lower() and array_upper() the number of array
Elements and their internal index may vary from record to record. Or may
even be absent.
Within the record the array nstat[],nwert[],nwho[] must correspond. 
Joining the table with
generate_series(array_lower(nWert,1),array_upper(nWert,1)) as indx

returns the contained array elements.


Considering the following table with array.....

Create table werte 
(id : integer, ...... ......nstat  : character(1)[],nwert  : double precision[],nwho   : character varying(9)[]
);


select
w.id,ii.indx,
w.nStat[ii.indx],w.nWert[ii.indx],w.nWho[ii.indx]
from werte w
join
(
select id,generate_series(array_lower(nWert,1),array_upper(nWert,1)) as indxfrom werte
) ii on ii.id=w.id 
;


Let me know what you think about this approach?


My best regards,


Stefan Becker




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

Предыдущее
От: "Pavel Stehule"
Дата:
Сообщение: Re: returning an array as a list fo single-column rows?
Следующее
От: Dani Castaños
Дата:
Сообщение: Different Query plans filtering between dates