SQL: get a substring by removing character off the right and left

hive, sql, string, substring

Solution

String operations in databases often vary among the different versions. In Hive, you want:

select substr(<val>, 2, length(<val>) - 2)

Problem

I have a column of values like: ``` [{"run_status":1,"daily_budget":"2000","campaign_id":"60952315"}]. ``` What is the query for removing the first and last bracket, so I am left with ``` {"run_status":1,"daily_budget":"2000","campaign_id":"60952315"} ``` If your answer is dependent on SQL version, I am using Hive.

Original source