简体   繁体   中英

"TRIM" in Bigquery

I have the "state" column in the table. In this state column, when I checked the length of values, I found one cell only showing value 3 remaining all are 2. "OH" in the state column. So it may be because of the space("OH "). So I want to remove the space using the TRIM function.

在此处输入图像描述

Still, after running, The length shows "3" for the particular one. If trims have happened, It should be shown 2 instead of 3. Why does this happen?

You should use LENGTH(TRIM(state)) if you want the length without blank spaces at the beginning or the end of state . Notice that LENGTH(" OH") is still 3, although in your WHERE , LENGHT(TRIM(" OH") = LENGTH("OH") and that is 2, so " OH" passes your where condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM