java hql中的区间表达式

0qx6xfy6  于 2022-12-02  发布在  Java
关注(0)|答案(2)|浏览(160)

I am trying to launch this sql with hql and it doesn't work due to '* interval' expression.
The sql calculates the avg in 5 mins intervals.
How could be changed the sql to make it works with hql?

SELECT date_trunc('hour', update_timestamp) + (( cast (date_part('minute', update_timestamp) as int) / 5) +1) * interval '5 min' AS minute
      ,  sum(t.free_spaces) as orders_count
FROM  myTable t
GROUP BY 1 ORDER BY 1 ASC
kq0g1dla

kq0g1dla1#

Hql不支持interval。您必须使用between。如果需要,您也可以使用本机查询。

cbwuti44

cbwuti442#

您可以使用make_interval函数。
我发现它可以与HQL查询一起工作,您可以像这样定义参数:
make_interval(年数)
make_interval(天=天数)
有关make_interval的更多信息,请参考以下网站:https://pgpedia.info/m/make_interval.html

相关问题