I want to query the Oracle 10g database and get result on the basis of residential address in ascending or descending order. So the problem is building addresses are at time in the form of 110C or 200D, so according to sql “order by” asc or desc, I get the result as 200D before 20.
for eg, if adresses are 10 110 112 200D 232 95 20 100A 1050 944
In ascending order it will result in:-
10 100 100A 1050 110 112 20 200D 232 944 95
The problem is as the adresses have characters in it, i can’t consider them to be as integers or number, they have to considered as String.
Use regular expressions:
REGEXP_SUBSTRwill find the number’s substring which is supposed to start the address, convert it to a real number and order by it.Caveat: you will have to improve the query to handle cases where a number will not be present. However, this answer can get you very well started.
When in need to fine-tune the query, here are the resources you should use:
And, yes,
REGEXP_SUBSTRis available in Oracle 10g.