我想将时间戳分组一段时间。
编辑问题 - 更改概念
我准备SQL:
SELECT s.start_interval, s.end_interval, count(a.create_time)
FROM (
SELECT start_interval, start_interval + ((b.close_date - b.open_date) / 5) AS end_interval
FROM b_table b
JOIN generate_series(b.open_date, b.close_date, (b.close_date - b.open_date) / 5) start_interval ON (1=1)
WHERE b.id = 1
) AS s
LEFT JOIN a_table a ON (a.create_time >= s.start_interval and a.create_time < s.end_interval and a.b_table_id = 1)
GROUP BY s.start_interval, s.end_interval;
(幻数5表示间隔)
我的SQL结果:
如何在JOOQ中解决此问题(例如,不支持generateSeries)?