Query to get only numbers from a string

前端 未结 14 2506
野性不改
野性不改 2020-11-22 06:17

I have data like this:

string 1: 003Preliminary Examination Plan   
string 2: Coordination005  
string 3: Balance1000sheet

The output I exp

14条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 06:17

    If you are using Postgres and you have data like '2000 - some sample text' then try substring and position combination, otherwise if in your scenario there is no delimiter, you need to write regex:

    SUBSTRING(Column_name from 0 for POSITION('-' in column_name) - 1) as 
    number_column_name
    

提交回复
热议问题