Hi,
I'm having trouble with how to apply the max() function to the result of a select. Right now my code looks like this:
session.beginTransaction();
Query hqlQuery = session
.createQuery("select m.nom, sum(s.quantite)"
+ " from Puzzle p, Magasin m, Stock s"
+ " where p.pieces between "+min+" and "+max
+ " and p.id = s.idJouet and m.id = s.idMagasin"
+ " group by m.nom");
That code works just fine. The thing is, I need to display only the m.nom of sum(s.quantite) biggest value (using max() I think). But I don't know how to do this.
I'm using Eclipse 3.2, Hibernate 3.3 and either Derby or MySQL (I think Derby doesn't support subselect btw). Any example code on how to solve this would be GREATLY appreciated.
|