SQLTeam.com | Weblogs | Forums

Problems with Extract

Hello to everyone.

I´m writing because I have a problem extracting the last value of a field

the code that i wrote is similar to this one

,substring(RUT,1,length(RUT)-1) AS TEST_1

the result that i need should look like this


Keep in mind that RUT is INTEGER so i don´t know is that could be a problem.


If RUT is an integer, then just SELECT RUT / 10 to drop the last digit.

Are you using SQL Server? I ask because "length" is not a function in SQL Server.

I`m using BigQuery in Google Cloud, it the first time I use it to write a code and for what i see it recognizes "length"

this is a microsoft sql server forum. you might get more mileage in a forum for bigquery but there might be someone that can answer that in this forum or this one


Thank you for the advice.
I was able to find the solution.

SUBSTR(cast(RUT as STRING), 1, LENGTH(cast(RUT as STRING))-1)

Glad this worked. I don't know about BigQuery, but seems to me, that the divide by 10 approach that robert suggested would avoid any implicit conversions