# Sorting by timestamp ASC doesn't work on QDB 9.4.2

**URL:** <https://community.questdb.com/t/sorting-by-timestamp-asc-doesnt-work-on-qdb-9-4-2/1005>\
**Category:** Community\
**Created:** [July 24, 2026, 6:57pm UTC](https://community.questdb.com/t/sorting-by-timestamp-asc-doesnt-work-on-qdb-9-4-2/1005 "2026-07-24T18:57:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@Gabriel](https://community.questdb.com/u/Gabriel)\
**Post date:** [July 24, 2026, 6:57pm UTC](https://community.questdb.com/t/sorting-by-timestamp-asc-doesnt-work-on-qdb-9-4-2/1005/1 "2026-07-24T18:57:08Z")

</div>

Hello,  
On a specific request the ordering by timestamp ascending is not working while the descending ordering works on QDB 9.4.2.

The initial request is:

```auto
SELECT * FROM (
SELECT a03.timestamp as timestamp, a03.n_pap_03, a03.s_pap_03, t03.n_03, t03.s_03 FROM 
((SELECT timestamp, sum(number) as n_pap_03, sum(surface) as s_pap_03 
FROM summary_object_stat WHERE class_name like 'CEL%' and timestamp > '2026-01' group by timestamp) timestamp(timestamp)) as a03
JOIN
((SELECT timestamp, sum(number) as n_03, sum(surface) as s_03 
FROM aisee_summary_object_stat WHERE timestamp > '2026-01'group by timestamp) timestamp(timestamp)) as t03 on a03.timestamp = t03.timestamp
 ) order by timestamp asc;

```

The corresponding EXPLAIN:

````auto
```
SelectedRecord
    Hash Join Light
      condition: t03.timestamp=a03.timestamp
        SelectedRecord
            Async Group By workers: 4
              keys: [timestamp]
              values: [sum(number),sum(surface)]
              filter: class_name like CEL% [state-shared]
                PageFrame
                    Row forward scan
                    Interval forward scan on: summary_object_stat
                      intervals: [("2026-01-01T00:00:00.000001Z","MAX")]
        Hash
            SelectedRecord
                Async Group By workers: 4
                  keys: [timestamp]
                  values: [sum(number),sum(surface)]
                  filter: null
                    PageFrame
                        Row forward scan
                        Interval forward scan on: summary_object_stat
                          intervals: [("2026-01-01T00:00:00.000001Z","MAX")]
```

````

And data are not returned ordered.

Changing the asc by desc in the request returns the data properly ordered in reverse orde. The corresponding EXPLAIN is:

````auto
```
Encode sort
  keys: [timestamp desc]
    SelectedRecord
        Hash Join Light
          condition: t03.timestamp=a03.timestamp
            SelectedRecord
                Async Group By workers: 4
                  keys: [timestamp]
                  values: [sum(number),sum(surface)]
                  filter: class_name like CEL% [state-shared]
                    PageFrame
                        Row forward scan
                        Interval forward scan on: summary_object_stat
                          intervals: [("2026-01-01T00:00:00.000001Z","MAX")]
            Hash
                SelectedRecord
                    Async Group By workers: 4
                      keys: [timestamp]
                      values: [sum(number),sum(surface)]
                      filter: null
                        PageFrame
                            Row forward scan
                            Interval forward scan on: summary_object_stat
                              intervals: [("2026-01-01T00:00:00.000001Z","MAX")]
```

````

The difference is clear.

---

<div class="post-metadata">

**Author:** ![Vlad\_Ilyushchenko](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.questdb.com/vlad_ilyushchenko/32/339_2.png) [@Vlad\_Ilyushchenko](https://community.questdb.com/u/Vlad_Ilyushchenko)\
**Post date:** [July 24, 2026, 9:08pm UTC](https://community.questdb.com/t/sorting-by-timestamp-asc-doesnt-work-on-qdb-9-4-2/1005/3 "2026-07-24T21:08:59Z")

</div>

```auto
   SELECT
       a03.timestamp AS timestamp,
       a03.n_pap_03,
       a03.s_pap_03,
       t03.n_03,
       t03.s_03
   FROM (
       SELECT timestamp, sum(number) AS n_pap_03, sum(surface)
 AS s_pap_03
       FROM summary_object_stat
       WHERE class_name LIKE 'CEL%' AND timestamp > '2026-01'
       GROUP BY timestamp
   ) a03
   JOIN (
       SELECT timestamp, sum(number) AS n_03, sum(surface) AS
 s_03
       FROM aisee_summary_object_stat
       WHERE timestamp > '2026-01'
       GROUP BY timestamp
   ) t03 ON a03.timestamp = t03.timestamp
   ORDER BY a03.timestamp ASC;

```
