Json_value 함수에서 $[0]은 무슨 의미인가요? 0 1 4,052

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]이 무슨 의미인가요? 구글링도 해보고 검색을 해봐도 나오지를 않네요.

by pajama [2020.12.25 11:22:33]

배열의 첫번째 값이라는군요~

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
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입