Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

VARCHAR2 sorting issue

dpsus4Aug 30 2022

Hi,
I'm facing a strange issue by querying a table and sorting a varchar2(20) column.
If a run this query:
SELECT SOTTOLOTTO, DUMP(SOTTOLOTTO)
FROM WMS_STO_VERSAMENTI
WHERE SOTTOLOTTO IN ('180075204000233113', '180075204000248384', '180075204000233441', '180075204000248148', '180075204000247998', '180075204000248728', '180075204000239269', '180075204000248872')
ORDER BY SOTTOLOTTO
the returned data is
SOTTOLOTTO DUMP(SOTTOLOTTO)
180075204000248872 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,52,56,56,55,50
180075204000248728 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,52,56,55,50,56
180075204000248384 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,52,56,51,56,52
180075204000248148 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,52,56,49,52,56
180075204000247998 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,52,55,57,57,56
180075204000239269 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,51,57,50,54,57
180075204000233441 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,51,51,52,52,49
180075204000233113 Typ=1 Len=18: 49,56,48,48,55,53,50,48,52,48,48,48,50,51,51,49,49,51
that is SOTTOLOTTO column is sorted in descending order rather than ascending (default).
DB collation parameters are:
NLS_LANGUAGE ENGLISH
NLS_TERRITORY ITALY
NLS_CURRENCY €
NLS_ISO_CURRENCY ITALY
NLS_NUMERIC_CHARACTERS ,.
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR HH24:MI:SS
NLS_DATE_LANGUAGE ENGLISH
NLS_CHARACTERSET AL32UTF8
NLS_SORT BINARY
NLS_TIME_FORMAT HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT DD-MON-RR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY €
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE

I don't know where I'm going wrong.
Thank you
Francesco

Comments
Post Details
Added on Aug 30 2022
28 comments
367 views