how to order records in stable query in TDengine?

50 Views Asked by At

I created a stable and a few sub-tables, then I used below SQL to list all records, but the result is not ordered by ts column. any way to do it?

select * from stable1

2

There are 2 best solutions below

0
xiaolei On

You can use order by to order your retrieved data.

select * from table order by ts;

example pic

For more infomation about order by you can refer search order by

0
zitsen On

You can use order by in a TDengine query sql statement, for example to sort a stable by ts column with descending order.

select * from log.dnodes_info order by ts desc