_대문 | 방명록 | 최근글 | 홈피소개 | 주인놈
FrontPage › PostgreSQLReference

Contents

[-]
1 배열에 번호 붙이기


1 배열에 번호 붙이기 #

--ver 9.4
--방법1
;with foo
as
(
	select 1 id, array['a','b','c'] val
	union all
	select 2 id, array['d','e','f'] val
)
select 
	a.id
,	a.val[b.seq] val
,	b.seq
from foo a
	cross join lateral generate_subscripts(val, 1) b(seq);

--방법2
;with foo
as
(
	select 1 id, array['a','b','c'] val
	union all
	select 2 id, array['d','e','f'] val
)
select
	a.id
,	b.val
,	b.seq
from foo a
	cross join lateral unnest(val) with ordinality b(val, seq);

댓글 남기기..
이름: : 오른쪽의 새로고침을 클릭해 주세요. 새로고침
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

사랑의 손길 앞에서는 누구나 시인이 된다. (플라톤)