同事,
非常基本的查詢。需要最后 10 條記錄。問題在于它的輸出方式,因為從最新到最舊開始,我需要最舊到新的。見下文
sqlite> SELECT * FROM raw_all_sensors order by timestamp desc LIMIT 10;
2022-03-10 16:43:58|26.43|19.19|1014|56.81|0|0|813|0
2022-03-10 16:38:57|26.49|19.19|1014|55.22|0|0|813|0
2022-03-10 16:33:56|26.58|19.19|1014|55.67|0|0|813|0
2022-03-10 16:28:55|26.68|19.19|1014|56.08|0|0|813|0
2022-03-10 16:23:54|26.77|19.19|1014|55.72|0|0|813|0
2022-03-10 16:18:52|26.88|19.19|1014|56.49|0|0|813|0
2022-03-10 16:13:51|26.99|19.19|1014|56.47|0|0|813|0
2022-03-10 16:08:50|27.07|19.19|1014|56.04|0|0|813|0
2022-03-10 16:03:49|27.14|19.19|1014|55.98|0|0|813|0
2022-03-10 15:58:48|27.3|19.19|1014|56.37|0|0|813|0
但是我需要
2022-03-10 15:58:48|27.3|19.19|1014|56.37|0|0|813|0
2022-03-10 16:03:49|27.14|19.19|1014|55.98|0|0|813|0
2022-03-10 16:08:50|27.07|19.19|1014|56.04|0|0|813|0
……
知道怎么做嗎?如果我做 asc(而不是 desc),它從最舊的記錄開始,不是我想要的
uj5u.com熱心網友回復:
我相信你想要的是:
select * from
(SELECT * FROM raw_all_sensors order by timestamp desc LIMIT 10) t
order by timestamp;
基本上在派生表中獲取您想要的 10 行,然后在外部查詢中以升序方式對它們進行排序。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/442096.html
標籤:sqlite
