How to do decimal precision in Spring Data Jpa @Query Annotation

I am trying to do the following query in the query annotation. I am using postgresSQL. However if I use "::numeric(10, 2)" in the query then I got syntax error at or near ":". But if I remove "::numeric(10, 2)" this, it works fine.

@Query(value = "SELECT AVG(feedback_rating)::numeric(10, 2) FROM app_customer_feedback WHERE " +
        "created_date >= to_timestamp(:dateFrom, 'yyyy-mm-dd hh24:mi:ss') AND " +
        "created_date < to_timestamp(:dateTo, 'yyyy-mm-dd hh24:mi:ss')", nativeQuery = true)
Double getAverageByDateRange(@Param("dateFrom") String dateFrom, @Param("dateTo") String dateTo);

Can anyone tell me how can I solve this problem? Thanks!



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation