SELECT ARRAY_AGG(T.NO1 ORDER BY T.NO1 ASC) AS ARR1
, ARRAY_AGG(T.NO2 ORDER BY T.NO2 DESC) AS ARR2
, ARRAY_AGG((T.NO1, T.NO2)) AS ARR3
, ARRAY_AGG(ARRAY[T.NO1, T.NO2]) AS ARR4
, ARRAY[ARRAY_AGG(T.NO1 ORDER BY T.NO1 ASC), ARRAY_AGG(T.NO2 ORDER BY T.NO2 DESC)]
AS MATRIX
, ARRAY_TO_JSON(ARRAY_AGG(T)) AS JSON1
, ARRAY_TO_JSON(ARRAY_AGG((T.NO1, T.NO2))) AS JSON2
, JSON_AGG(JSON_BUILD_OBJECT('A', T.NO1, 'B', T.NO2)) AS JSON3
FROM (SELECT NO AS NO1
, NO * 10 AS NO2
FROM GENERATE_SERIES(1, 10) NO) T
;
SELECT T.ARR1[1] -- 1번째행 1
, T.ARR2[2] -- 2번째행 90
, T.ARR3[3] -- 3번째행 (3,30) <- 이건 문자형이다.
, T.ARR4[1:1]
, T.ARR4[1:2]
, T.ARR4[1:3]
, T.ARR4[2:2][1:1]
, T.ARR4[2:2][2:2]
, T.MATRIX[1:1] -- 1번째열, 1~끝까지
, T.MATRIX[2:2][1:4] -- 2번째열, 1~4행
FROM (SELECT ARRAY_AGG(T.NO1 ORDER BY T.NO1 ASC) AS ARR1
, ARRAY_AGG(T.NO2 ORDER BY T.NO2 DESC) AS ARR2
, ARRAY_AGG((T.NO1, T.NO2)) AS ARR3
, ARRAY_AGG(ARRAY[T.NO1, T.NO2]) AS ARR4
, ARRAY[ARRAY_AGG(T.NO1 ORDER BY T.NO1 ASC), ARRAY_AGG(T.NO2 ORDER BY T.NO2 DESC)]
AS MATRIX
FROM (SELECT NO AS NO1
, NO * 10 AS NO2
FROM GENERATE_SERIES(1, 10) NO) T
) T
;