I am running a query in Oracle and that query is ordered by a column that may have values with ampersand. However, it seems that ampersand is being ignored by the sorting algorithm.
For instance:
select * from (
select '&' txt from dual
union
select 'P' txt from dual
union
select 'N' txt from dual
)
order by txt
Prints exactly (and correctly, I guess):
&
N
P
However, if I change the text with '&' to '&Z', the result changes:
select * from (
select '&'||'Z' txt from dual // concatenating just to
// avoid variable substitution
union
select 'P' txt from dual
union
select 'N' txt from dual
)
order by txt
Result is then:
N
P
&Z
If I change 'Z' to 'A' then the result is:
&A
N
P
It seems that the '&' is not being considered by ORDER BY clause. Does anyone know if this is expected behavior or if I am missing some configuration step? I understand that one needs to escape ampersand for inserts or updates. But thing is that the character is already in the table!
Thanks in advance, guys.