1

I am using postgres and some of my table's field are arrays. I am looking for the biggest array is there any way to find this info with a SQL statement ?

CREATE TABLE chapter
(....
chapter_path integer[],
.....)

My chapter path are like that {x,y,z} {x,y} {x}

How with a SQL statement can I get 3 corresponding to {x,y,z} integer array size ?

1 Answer 1

4

Use array_upper().

Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately, my arrays are arrays of uuid and not simple integer I put it up for the demo. Thanks anyway for the answer.
The array_lenght function of the page you gave me made the trick. Thank You !
@Frank , is there a difference between array_upper() and array_length() ?? Is there an advantage of using one over the other? or are there situations where you must use one and not the other?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.