0
I have the following query to get Notapt (category = 3)
how can in the same query get the Notamt (category = 11)
I am trying so, but I get the same value for Notapt and Notamt, below code and output image:
select u.firstname as Aluno, u.lastname as escola, userid, u.department as turma, q.category as cat,
(select avg(fraction)*10 where cat = 3) as NotaPT,
(select avg(fraction)*10 where cat = 11) as NotaMT
FROM mdl_question_attempt_steps qas
inner join mdl_user u on u.id=qas.userid
INNER JOIN mdl_question_attempts qa ON qa.id=qas.questionattemptid
INNER JOIN mdl_question q On q.id=qa.questionid
group by userid, turma
order by turma asc, NotaPT DESC
It would not be enough to group also by category and select the ones you want to calculate?
– Woss
@Andersoncarloswoss as I could do it, just add the column
category
in GROUP BY? and how would you separately obtain the Portuguese and Math grades of each Student? I can already catch the Portuguese notes (3) but I don’t know how to call Mathematics (11), using the same information of Portuguese changing only the category. I broke my head but I couldn’t– Miguel Silva
@Andersoncarloswoss worked out by grouping by category too, Thank you!
– Miguel Silva