I have problem with sorting elements by varchar containing Polish characters like ą, Ą.
For example, we have following names:
Aaaa
BBcvx
Ąccc
Ddde
ądcc
Following query:
select * from something order by lower(name);
Returns result as this:
Aaaa
BBcvx
Ddde
ądcc
Ąccc
As you can see, polish characters are ignored and put at the end. It should be:
Aaaa
ądcc
Ąccc
BBcvx
Ddde
What might be the problem? Database encoding? Mine is:
SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = 'NLS_CHARACTERSET';
Result:
EE8MSWIN1250
Can this be fixed without changing database encoding?
You need to look into the NLS_SORT parameter, specifically linguistic sorting. You can use this parameter to specify what language you’d like to sort by. I suspect in your case it would be
POLISH.Something like this
NLS_LOWER()returns a lower case character in the same manner as an ordinaryLOWER().You could also do this at a session level, which would change the default sort parameter for the duration of the session.
If you wanted to always use this sort; this is done the database level when the database is created.