我试图使用 date_trunc 对一组数据进行分组。但在执行数据后,我得到了日期格式(DD/MM/YY)的分组数据。如何使用查询将其排在第二位?
桌面传感器
----------------------------------
| sensorid | reading | timestamp |
----------------------------------
| 1 | 100 | 1612331498 |
-----------------------------------
| 2 | 100 | 1614752263 |
-----------------------------------
| 1 | 10 | 1614752263 |
-----------------------------------
> select date_trunc('day', v.timestamp) as day,sum(reading) from sensor
> v(timestamp,sensorid) where sensorid=1 group by (DAY);
Output is
day sum
03/02/2021 12:00:00 am 100
03/03/2021 12:00:00 am 10
Expected result
day sum
1612331498 100
1614752263 10
我正在使用 Npgsql C# 客户端和 cratedb。
CREATE TABLE sensor (
sensorid int,
reading double,
timestamp double
);