Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Redshift SQL to remove text after a space

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…

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Query tried

Select regex_replace(model,'','')

>Solution :

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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading