BigQuery How to return the first value of array?

In BigQuery, an array is an ordered list consisting of zero or more values of the same data type. You can construct arrays of simple data types, such as INT64, and complex data types, such as STRUCTs. The current exception to this is the ARRAY data type: arrays of arrays are not supported.

How can I select the first value of array with BigQuery Standard SQL?

You can use either OFFSET() or ORDINAL(). The method would be:

select array[offset(0)]

or

select array[ordinal(1)]

Ryan-Dallas

posted on 16 Sep 18

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds