JOBQ中的GroupBy时间戳间隔

时间:2018-06-18 18:20:45

标签: spring postgresql kotlin jooq

我想将时间戳分组一段时间。

编辑问题 - 更改概念

我准备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结果:

enter image description here

如何在JOOQ中解决此问题(例如,不支持generateSeries)?

0 个答案:

没有答案