Oracle timestamp sort order

I noticed some weird sort order when sorting by timestamp. First, it sorts by time part of the timestamp, and then the sort date is used for records with the same time.

For me it looks completely wrong. Is there a way to tell Oracle to sort by date and then by time?

Thank.

The field is defined as TIMESTAMP (6), without a time zone. Here is the sort result:

10-JAN-11 11.18.36.368000000 AM
09-JAN-11 11.18.33.700000000 AM
08-JAN-11 11.18.33.704000000 AM
07-JAN-11 11.18.33.700000000 AM
06-JAN-11 11.17.40.705000000 AM
05-JAN-11 11.17.42.611000000 AM
04-JAN-11 11.17.40.723000000 AM
02-JAN-11 04.45.09.553000000 PM
01-JAN-11 04.45.08.447000000 PM
31-DEC-10 04.45.08.447000000 PM
30-DEC-10 04.35.22.153000000 PM
29-DEC-10 04.30.25.334000000 PM
12-JAN-11 12.00.00.000000000 AM
11-JAN-11 12.00.00.000000000 AM
10-JAN-11 12.00.00.000000000 AM
09-JAN-11 12.00.00.000000000 AM
08-JAN-11 12.00.00.000000000 AM
07-JAN-11 12.00.00.000000000 AM

Here is the request:

select period_end from table_name where entity_id=102167 order by period_end desc;
+3
source share
2 answers

Dima,

The format of your timestamp shows all the components of a timestamp except one: eyelid. Your last six lines should be in the last century.

Regards,
Rob.

+8
source

, timestamp with timezone.

0

Source: https://habr.com/ru/post/1784943/


All Articles