hibernate - How to write group by as in hql? -


i wrote hql this:

select date_format(createat, '%y-%m-%d') day, sum(amount) orderamount      foodorder deleted = 'false' , orderstate = ?1     , createat between ?2 , ?3 group day order day 

i got error: unknown column 'day' in 'group statement'.

and hibernate log this:

select     date_format(foodorder0_.create_at,     '%y-%m-%d') col_0_0_,     sum(foodorder0_.amount) col_1_0_     food_order foodorder0_     foodorder0_.deleted='false'     , foodorder0_.order_state=?     , (         foodorder0_.create_at between ? , ?     ) group     day order     col_0_0_ 

why order use col_0_0_ group use "day" , got error?

any thanks!

yes, bonifacio's answer, should be:

group date_format(createat, '%y-%m-%d') 

sorry late comment this, , can not set bonifacio best answer time.


Comments