SELECT id, comment, team_name
from XYZ
INNER JOIN (
SELECT id
from ABC
where team.id= "XYZ"
GROUP BY id
ORDER BY COUNT(id) DESC
) on XYZ.id=ABC.id where XYZ.id="ABC"
该问题的解决方案是什么,因为我无法对HQL中的子查询进行内部联接。
答案 0 :(得分:0)
解决方案是仅对所有列使用GROUP BY
SELECT s.assignedTo.id, s.assignedBy.id, s.comment, s.assignedTo.team.team_name, COUNT(s.assignedTo.id)
FROM Star s
WHERE s.assignedTo.team.team_id=:teamName
GROUP BY s.assignedTo.id,s.assignedBy.id, s.comment,s.assignedTo.team.team_name
ORDER BY s.assignedTo.id;