错误:运算符不存在:没有时区的时间> = bytea

时间:2019-03-20 10:11:24

标签: postgresql hibernate spring-data-jpa

我收到这样的错误

ERROR: operator does not exist : time without time zone >= bytea 
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

当我在java hibernate中尝试以下sql时

select sto.name AS store, 
       sum(odi.subtotal_price) AS sales, sum(odi.qty) AS qty_sold,
       ((sum(odi.subtotal_price))/(sum(odi.qty))) AS average, 
       min(CAST(ord.date_out AS date)) AS start_date,
       max(CAST(ord.date_out AS date)) AS end_date,
       concat(min(CAST(ord.date_out AS time)), ' - ', max(CAST(ord.date_out AS time))) as time,
       sum(odi.cost_of_good_sold*odi.qty) AS COGS, ((sum(odi.cost_of_good_sold*odi.qty))/(sum(odi.qty))) AS average_cogs,
       date_trunc('day', ord.date_out) AS trx_day
FROM trx_order_detail_item odi
LEFT JOIN trx_order AS ord on ord.id = odi.order_id
LEFT JOIN mst_store AS sto on sto.id = ord.store_id
WHERE sto.id = :store and ord.date_out between :date1 and :date2 
      and CAST(ord.date_out AS TIME) BETWEEN :hour1 AND :hour2 and ord.order_status_id IN :orderstatus and ord.void_status = :voidStatus
GROUP BY sto.name, date_trunc('day', ord.date_out)
ORDER BY date_trunc('day', ord.date_out)

该错误存在于CAST(ord.date_out AS TIME) BETWEEN :hour1 AND :hour2中 在我补充说它运行完美之前 有什么建议吗?

0 个答案:

没有答案