我使用Postgre在SQLPad中有以下代码,我需要在Google BigQuery中执行相同的功能。备注:
select (jsonb_array_elements(cars)) -> 'tires' as number_of_wheels from my_table`
oug3syen1#
我认为下面将返回与PostgreSQL相同的结果。
WITH my_table AS ( SELECT '''[ {"model":"hyundai", "tires":4, "type":"SUV"}, {"model":"honda", "tires":4, "type":"Sedan"} ]''' cars ) SELECT JSON_VALUE(car, '$.tires') AS number_of_wheels FROM my_table, UNNEST(JSON_QUERY_ARRAY(cars)) car; -- Query results +------------------+ | number_of_wheels | +------------------+ | 4 | | 4 | +------------------+
1条答案
按热度按时间oug3syen1#
我认为下面将返回与PostgreSQL相同的结果。