无论如何在JPQL中表示这个sql查询,我对SUM(IF)部分有困难。提前感谢您的帮助。
SELECT username,
SUM(IF(`first` = firstPar,1,0)) firstCount,
SUM(IF(`second` = secondPar,1,0)) secondCount,
SUM(IF(`third` = thirdPar,1,0)) thirdCount
FROM rounds
LEFT JOIN courses
ON 1
GROUP BY username
不重复,因为建议的问题不使用JOIN或多个SUM