要从测量中选择最新的100个数据点,请使用以下查询:
select field1, field2 from measurement
where time < now()
order by time desc limit 100
但是我需要按升序排列值。目前我在我的应用程序中反转结果,这是昂贵的。
我也试过了子查询,但没有成功:
select field1, field2 from
(select * from measurement
where time <= now()
order by time desc limit 100) order by asc
答案 0 :(得分:0)
您可以将此查询用作锻炼
select * from measurement where time <= now() and time >= now() - "some time you defined" limit 100
尽管您必须谨慎定义时间。