How to get the last element of an array in PostgreSQL?
问题 The PostgreSQL Documentation on arrays provides an example using [-1] to access what appears to be the last element of an array; however while SELECT arr[2:3]; produces {5,9} , arr[2:-1] results in {} . How can the last element of an array be obtained in PostgreSQL? Edit: Windows, PostgreSQL v9.2.1 回答1: I think you're misinterpreting the example. PostgreSQL arrays don't have to be indexed from 1 to n , that's just the default: By default PostgreSQL uses a one-based numbering convention for