lundi 26 février 2018

Laravel compare values in two tables

I'm trying to find whether a student percentage mark is less than or above the average of the whole class. Those two values are in different tables and using whereRaw is only working when checking whether the percentage and average mark are equal, checking whether the student percentage is above the average mark is returning even the ones there it is below average. How should I approach this.

$above_average = DB::table('quiz_percentage')
->join('quiz_average', 'quiz_average.quiz_id', '=', 'quiz_percentage.quiz_id')
->where('quiz_percentage.student_id', $student_id)
->where('quiz_percentage.grade_id', $grade_id)
->whereRaw('quiz_average.average_mark >= quiz_percentage.percentage')
->get();



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2osbAHk
via IFTTT

Aucun commentaire:

Enregistrer un commentaire