Is there an option to make MySQL's Group_Concat function include -ve values and zeros ?
Consider the following example from my source table:
Id, question, mark
10, 3, -10
10, 4, 0
10, 5, 2
10, 8, 1
When I query on the selection table for rank calcultaion with GROUP_CONCAT, I get the following:
Id, question, mark ,rank
10, 5, 2 ,1
10, 8, 1 ,2
I would like to get the following:
Id, question, mark ,rank
10, 5, 2 ,1
10, 8, 1 ,2
10, 4, 0 ,3
10, 3, -10 ,4
For reference, my query looks like this:
SELECT *,FIND_IN_SET( mark , (
SELECT GROUP_CONCAT( mark
ORDER BY mark DESC )
FROM exam_score )
) AS rank
FROM exam_score
ORDER BY rank asc
Aucun commentaire:
Enregistrer un commentaire