Avatar of Basssque
Basssque

asked on 

Address column split and case when statements

I'm currently using the following statement to split address columns
SUBSTR(STREET, 1, INSTR(STREET, ' ')-1) AS HouseNumber,
SUBSTR(STREET, INSTR(STREET, ' ')+1) AS Street,

In this case, 50 Main St is split into two columns
50, Main St

Is it possible to add a third column to split letters out from the house number?
In this case 50D Main St is out put like 50,D,Main St AND 50 Main St would be output like 50,,Main St

I also need to strip leading spaces from the Street after the split or replace instances of more than one space with a single space prior to the split

Last, if I have an House_Number values of
100
200
50
How can I sort them in order so 50 comes before 100 opposed to after 200?

Thanks!!!
Oracle DatabaseSQL

Avatar of undefined
Last Comment
Basssque

8/22/2022 - Mon