
Answer-first summary for fast verification
Answer: products[0]
The question asks for the first element in a nested array column named 'products'. In SQL, array elements are accessed using bracket notation with zero-based indexing, where the first element is at index 0. Option C ('products[0]') correctly uses this syntax to retrieve the first element. Option B ('products.0') uses dot notation, which is incorrect for array element access in SQL. Option A ('products.1') and Option D ('products[1]') would retrieve the second element (index 1), not the first. The community discussion shows 100% consensus on B, but this appears to be a mismatch with the correct SQL syntax, as bracket notation is standard for array access.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A data analyst is working with a table named transactions that contains a nested array column named products. The analyst needs to return the first element from the array for each row.
The analyst is using the following incomplete command:
SELECT
_____
FROM
transactions;
SELECT
_____
FROM
transactions;
Which line of code should the data analyst use to fill in the blank to successfully complete this task?

A
products.1
B
products.0
C
products[0]
D
products[1]
No comments yet.