- I am averaging 4 columns and giving an alias
score. - Now, I am trying to use
scorealias inside GROUP_CONCAT to getrank. - Everything works except when I add
(SELECT GROUP_CONCAT( score ORDER BY score DESC) FROM math )) AS rank. - I understand it does not work because
scoredoes not exist in themathtable. But what do I need to do to make it work?
Here is my query in laravel 5.5 -
$ranking = DB::select('SELECT *, (a.addition_accuracy + a.subtraction_accuracy + a.multiplication_accuracy + a.division_accuracy)/4 as score, (SELECT GROUP_CONCAT( score ORDER BY score DESC) FROM math )) AS rank FROM math a where level = 5');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire