How can I write the below HQL query using the Criteria API?
select s.Name, sum(q.PointsObtained), sum(q.TotalPoints)
from Student s join s.Quizzes q
group by s.Name
order by (sum(q.PointsObtained) / sum(q.TotalPoints)) desc
How can I write the below HQL query using the Criteria API?
select s.Name, sum(q.PointsObtained), sum(q.TotalPoints)
from Student s join s.Quizzes q
group by s.Name
order by (sum(q.PointsObtained) / sum(q.TotalPoints)) desc
It's not supported by HQL or the Critieria API. See 14.12. The group by clause: "Neither the group by clause nor the order by clause can contain arithmetic expressions." I assume you mean SQL query, not HQL query, in your question.