Reputation: 421
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,'','')
Upvotes: 0
Views: 861
Reputation: 11
You can split your input string on ' ' and then take the first part. Sample code (Redshift) :
SELECT model, SPLIT_PART (model, ' ', 1) as model_processed
FROM yourTable;
Documentation link : https://docs.aws.amazon.com/redshift/latest/dg/SPLIT_PART.html
Upvotes: 1
Reputation: 521249
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;
Upvotes: 1