PostgreSQL – ARRAY_POSITION Function
ARRAY_POSITION function in PostgreSQL is used to return the position of the first occurrence of an array element.
Here is the basic syntax of using array_position function.
SELECT array_position(your_array_column, int)) AS position FROM your_table ;
Example of using array_position function:
SELECT array_position(array(20, 10, 10, 30), 10) AS position;
The output would be 2 ; as 10 is in the second position and third position. However, the first occurrence of 10 is in the second position.