hql distinct order -


hi need select distinct objects ordered newest subobject, how can this? tried select parent-objects subobjects:

select distinct r.forumtheme forumresponse r order r.responseid desc 

i

order items must appear in select list if select distinct specified. 

and when try this:

select distinct r.forumtheme,r.responseid forumresponse r order r.responseid desc 

the result isnt distinct: forumtheme can appear multible times different responseid

is there solution?

for given forumtheme, have several responseids. how should sorted? [6, 3, 2] greater or lower [5, 4, 2]?

this why can't order by.

you should execute following query:

select r.forumtheme, max(r.responseid) forumresponse r  group r.forumtheme order max(r.responseid) 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -