by 반집의승리 [SQL Query] oracle json_arrayagg json_value [2020.12.25 10:23:17]
select json_value( replace( json_arrayarr(rpad(p.name, 20) order by product_id returning clob) , ' " , " ' , ' ' ) , '$[0]' returning clob ) as product_list from products p join monthly_sales ms on ms.product_id = p.id;
안녕하세요. json_arrayagg에 대해서 모르는 것이 생겨 질문을 올리게되었습니다.
9번째 줄에서 $[0]이 무슨 의미인가요? 구글링도 해보고 검색을 해봐도 나오지를 않네요.
배열의 첫번째 값이라는군요~
https://docs.oracle.com/database/121/SQLRF/functions093.htm#SQLRF56668
The following query returns the value of the first element in an array:
SELECT JSON_VALUE('[0, 1, 2, 3]', '$[0]') AS value FROM DUAL; VALUE ----- 0