1

I have an array of type character.

For ex: {AA,BB,CC,DD,EE,FF,GG, hh, II, jj,KK}

From the above array i need to extract for ex: from 3rd position to 7th position which is {CC,DD,EE,FF,GG}

Please let me know how to achieve this.

1 Answer 1

2

If you know the positions, you can simple do this:

SELECT myarray[3:7] FROM mytable ...;
1
  • 1
    +1, I'd also add that PostgreSQL have 1-based indexing, which is not very common Sep 12, 2013 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.