I have a table as below
timestamp v1 v2 v3
2020/01/01 08:10:20.300 10 20 30
2020/01/01 08:10:20.306 11 21 31
2020/01/01 08:10:20.310 12 22 32
2020/01/01 08:10:20.318 13 23 33
2020/01/01 08:10:20.325 14 24 34
.......................
2020/01/01 08:10:21.100 19 29 39
As can be seen that the timestamp does not change uniformly in the millisecond and has a lot of granular data. I am interested to condense the table such that, the timestamp and data columns average out for every 100 millisecond ie all the data between 100 millisecond gets averaged out.
I have a solution that seems to be working but the average is over every second and not after every 100 millisecond.
SELECT date_trunc('second', timestamp) AS timestamp
,avg(v1) AS avg_v1
,avg(v2) AS avg_v2
,avg(v3) AS avg_v3
FROM myTable
GROUP BY 1;
Please direct me how to solve this issue. Thank you