これまでのところ、このクエリに苦労していますが、1 分の間隔を作成できますが、必要な 2 つの列の合計はその分だけであり、時間の経過に伴う累積合計ではありません。
SELECT
TIMESTAMP WITH TIME ZONE 'epoch' +
INTERVAL '1 second' * round(extract('epoch' from "Timestamp") / 60) * 60 as Timestamp",
SUM("Particles"), sum("Bio")
from "Results"
where "SampleID" = 50
GROUP BY round(extract('epoch' from "Timestamp") / 60)
ORDER BY "Timestamp" DESC
それは私が使用しているクエリであり、結果はこれらです
Timestamp |Sum |Sum
"2013-08-09 14:17:00-07" | 61 | 4
"2013-08-09 14:16:00-07" | 64 | 6
"2013-08-09 14:15:00-07" | 29 | 5
"2013-08-09 14:14:00-07" | 96 | 1
"2013-08-09 14:13:00-07" | 43 | 2
しかし、最後の2つの列の累積合計が必要です
Select
TIMESTAMP WITH TIME ZONE 'epoch' +
INTERVAL '1 second' * round(extract('epoch' from "Timestamp") / 60) * 60 as "Timestamp",
sum("Particles") over (order by "Timestamp") as Cumulative_Part,
sum("Bio") over (order by "Timestamp") as Cumulative_Bio from "Results"
where
"SampleID" = 50 and
"Timestamp" between '2013-08-09 14:13:00' and '2013-08-09 14:17:00'
GROUP BY round(extract('epoch' from "Timestamp") / 60)
Order by "Timestamp" DESC