Home > OS >  Redshift SQL to remove text after a space
Redshift SQL to remove text after a space

Time:07-22

I am trying to remove the text after space from the below example (the name of the data field is model

R17245 20 should return just R17245

FG789 32 should return just FG789...

Query tried

Select regex_replace(model,'','')

CodePudding user response:

Assuming the logic here is to remove everything from the first space onwards, you may use:

SELECT model, REGEXP_REPLACE(model, ' .*$', '') AS model_out
FROM yourTable;
  • Related