Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

masumluf's avatar

@jlrdw I found the solution

SELECT SUM(mark),student_username FROM exams WHERE exam_type='FINAL' GROUP BY student_username HAVING MIN(mark) >= 50

but how can I write it in laravel eloquent standard ? I'm getting error when i put min caluse in having function?

jlrdw's avatar

@nakov funny that havingRaw would work since the clause there was not an aggregate but a direct mark.

By all right having should have worked.

One of the reasons I usually just use straight PDO.

rushabhmadhu's avatar

In Having clause you can pass conditions for group by field only, (Having is a condition on group by clause result) so if you want to ignore failed student you have to add conditions of each subject in where clause.

Please add where clause for each subject>40

I hope you get this.

Previous

Please or to participate in this conversation.