Saya perlu mengelompokkan berdasarkan periode waktu hingga 10 menit.
Saya memiliki kueri di bawah ini yang mengembalikan saya set hasil:
SELECT timestamp
FROM table_1, table_2_shape_polygon
WHERE ST_Within(earthnetworks_geometry_raios, poligono_geometry)
AND timestamp
BETWEEN '2013-04-07 15:30:00' AND '2013-04-07 16:50:00'
AND type = 0
AND id_polygon = 2
Kumpulan hasil saya adalah seperti ini:
"2013-04-07 15:30:55"
"2013-04-07 15:32:52"
"2013-04-07 15:32:52"
"2013-04-07 15:34:21"
"2013-04-07 15:39:09"
"2013-04-07 16:24:25"
"2013-04-07 16:29:58"
"2013-04-07 16:33:22"
"2013-04-07 16:34:30"
"2013-04-07 16:35:09"
"2013-04-07 16:36:54"
"2013-04-07 16:38:40"
"2013-04-07 16:39:37"
"2013-04-07 16:39:37"
"2013-04-07 16:39:38"
"2013-04-07 16:39:38"
"2013-04-07 16:39:44"
"2013-04-07 16:39:56"
"2013-04-07 16:40:03"
"2013-04-07 16:40:04"
"2013-04-07 16:41:22"
"2013-04-07 16:41:27"
"2013-04-07 16:41:38"
"2013-04-07 16:41:38"
"2013-04-07 16:42:24"
"2013-04-07 16:42:39"
"2013-04-07 16:45:00"
"2013-04-07 16:45:40"
"2013-04-07 16:49:43"
Saya memiliki semua cap waktu di antara satu periode, tetapi saya perlu mengelompokkannya setiap 10 menit dan saya tidak tahu caranya. Saya mencoba date_trunc
yang tidak memiliki ketelitian yang saya butuhkan.
mis: antara 2013-04-07 15:30:00, 2013-04-07 15:40:00 5 results
.
Bagaimana saya bisa melakukan ini?
Saya mencoba ini dan itu tidak berhasil seperti yang diharapkan.
SELECT
timestamp 'epoch' +
INTERVAL '1 second' * round((extract('epoch' from earthnetworks_dt_horario) / 600) * 600) as horario,
count(earthnetworks_dt_horario)
FROM raios.earthnetworks, raios.earthnetworks_teste_poligono
WHERE ST_Within(earthnetworks_geometry_raios, poligono_geometry)
AND earthnetworks_dt_horario
BETWEEN '2013-04-07 15:30:00' AND '2013-04-07 16:50:00'
AND earthnetworks_num_tipo = 0
AND id_poligono = 2
GROUP BY
round(extract('epoch' from earthnetworks_dt_horario) / 600), earthnetworks_dt_horario
Ini adalah set hasil yang tidak dikelompokkan:
"2013-04-07 16:29:58";1 "2013-04-07 16:34:30";1 "2013-04-07 16:33:22";1 "2013-04-07 16:39:44";1 "2013-04-07 16:39:56";1 "2013-04-07 16:42:24";1 "2013-04-07 16:41:38";2 "2013-04-07 16:24:25";1 "2013-04-07 16:39:38";2 "2013-04-07 16:42:39";1 "2013-04-07 16:41:27";1 "2013-04-07 16:36:54";1 "2013-04-07 16:45:00";1 "2013-04-07 16:40:04";1 "2013-04-07 16:40:03";1 "2013-04-07 15:34:21";1 "2013-04-07 15:30:55";1 "2013-04-07 15:39:09";1 "2013-04-07 16:49:43";1 "2013-04-07 16:45:40";1 "2013-04-07 16:35:09";1 "2013-04-07 16:38:40";1 "2013-04-07 16:39:37";2 "2013-04-07 16:41:22";1 "2013-04-07 15:32:52";2
Tidak berfungsi.
|| ' minutes'
digunakan didate_part
.