PostgreSQL – How to Remove Numbers Before First Comma

postgresqlupdate

I am new to SQL however, I am looking to update a table where column called "scrap_value" and rows contains a set of numbers in an array e.g.
{100000,125000,150000,175000,200000}

I want to remove the first number and comma of all rows in "scrap_value", so the end result looks like this
{125000,150000,175000,200000}

How would I got about doing this?

Best Answer

That looks like an array. If that is the case, you can remove the first element of the array using an UPDATE statement:

update the_table
  scrap_value = scrap_value[2:];

[2:] selects all elements of the array starting with the second. The result of that is then used to override the existing array.