IFNULL equivalent in Hibernate Query Language?

后端 未结 2 1548
夕颜
夕颜 2021-02-07 09:51

I\'m trying to write an HQL query which will calculate an average rating for an item. I want the query to return 0 instead of null when there are no rating for a given item - so

2条回答
  •  误落风尘
    2021-02-07 10:50

    COALESCE is the official equivalent.

    It returns the first non-null of its arguments.

    Example:

        COALESCE(id_pati, 0)
    

    Link Wikipedia

提交回复
热议问题