Multiple split and assign order_id

后端 未结 1 1877
梦毁少年i
梦毁少年i 2021-01-20 08:27

I have some address string that needs to be analyzed for each component.

SQL Fiddle Demo

CREATE TABLE Table1 (\"ID\" int, \"address\         


        
相关标签:
1条回答
  • 2021-01-20 08:56

    Use translate():

    SELECT "ID", token, row_number() over (partition by "ID")
    FROM (
        SELECT "ID", s.token
        FROM   
            Table1 t, 
            unnest(string_to_array(translate(t.address, '.,:;-', '     '), ' ')) 
                s(token)
        WHERE token <> ''
        ) sub
    

    SqlFiddle.

    0 讨论(0)
提交回复
热议问题