Home > Software engineering >  PostgreSQL timescale - How to sort rows by time and id?
PostgreSQL timescale - How to sort rows by time and id?

Time:05-02

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

CodePudding user response:

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.

  • Related