'PostgreSQL timescale - How to sort rows by time and id?

I have data in my timescale database. If we only look at the "time", everything is fine. But if we look at the "id" we can see that 152 and 153 numbers didn't sort by id! They have the same time, but different id.

How sort 152 and 153 number by time and id in timescale?enter image description here



Solution 1:[1]

Looking at output you are showing, I am seeing output is sorted by descending order of time. If you want to order your output by descending order of both id & time then you can try below:

select * from timescale order by id , time desc;

Hopefully this is what you are looking for.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ashish Patil