PostgreSQL – ARRAY_POSITIONS Function

ARRAY_POSITIONS function returns the positions of all occurrences of an array element. Here is the basic syntax of using the ARRAY_POSITIONS function.

SELECT ARRAY_POSITIONS(array[2,1,3,1,2],1);

Above sql returns 2,4 as the output as element ‘1’ occurred in both 2nd and 4th position.

Similar Posts