2

I tried array_upper(array(Value)) and array_upper((Value):array[]) but was getting syntax error.

Value : data type is int []; I am expecting the result as below table:

 Pname  week_date      Value    array_length
    5773    6/8/2013    {29}            1
    5773    3/30/2013   {27}            1
    5773    3/16/2013   {138,3,4}       3
    5773    3/9/2013    {37,8}          2
    5773    1/19/2013   {66}            1
    5773    1/5/2013    {49,50,50,56}   4

But this works fine

select array_upper(array[1,2,3,6], 1)

I need to use Value column and find out the length of that value array

postgres version : 8.2

2
  • 3
    8.2 is past end of life. You need to upgrade. Commented Feb 27, 2014 at 20:09
  • I cannot as I am using green plum and it runs on 8.2 postgres by default. Commented Feb 27, 2014 at 20:10

1 Answer 1

5

That should work:

select array_upper ( value, 1 ) from table_name_here;

Note: 'VALUE' is reserved keyword in SQL, so it is not recommended to use it as a column name. See: http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html

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

2 Comments

no it doesnt work it throws an error : function array_upper(integer[]) does not exist
@user2569524: PostgreSQL 8.2 has array_upper(anyarray,int) so it should work. Your error message suggests that you're trying to use array_upper(value) instead of array_upper(value, 1).

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.