Guest User

Untitled

a guest
Nov 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. SELECT qs.slot as Questao, avg(fraction) * 10 as Media, qs.quizid as Quiz, qs.questionid as QuestaoID, q.name as Descritor, SUBSTRING(u.`department`,2,4) as Nivel, SUBSTRING(u.`department`,6,1) as Turma, q.category as cat, quiz.name as Simulado,
  2.  
  3. (Select institution
  4. from fhrw_user totalEscolasU
  5.  
  6. INNER JOIN fhrw_quiz_attempts totalEscolasQa ON totalEscolasQa.userid=totalEscolasU.id
  7. INNER JOIN fhrw_quiz totalEscolasQ ON totalEscolasQ.id=totalEscolasQa.quiz
  8. where totalEscolasQ.name=$P{simulado}
  9. and totalEscolasU.lastname=lastname
  10. and SUBSTRING(totalEscolasU.`department`,1,5) = $P{nivel}
  11. and SUBSTRING(totalEscolasU.`department`,6,1) = $P{turma}
  12. and totalEscolasQa.state="finished"
  13. ) as totalEscolas,
  14.  
  15. (Select count(totalAlunosQa.id)
  16. from fhrw_quiz_attempts totalAlunosQa
  17.  
  18. INNER JOIN fhrw_user totalAlunosu ON totalAlunosu.id=totalAlunosQa.userid
  19. INNER JOIN fhrw_quiz totalAlunosq ON totalAlunosq.id=totalAlunosQa.quiz
  20. where totalAlunosq.name=$P{simulado}
  21. and totalAlunosu.lastname=lastname
  22. and SUBSTRING(totalAlunosu.`department`,1,5) = $P{nivel}
  23. and SUBSTRING(totalAlunosu.`department`,6,1) = $P{turma}
  24. and totalAlunosQa.state="finished"
  25. ) as totalAlunos,
  26.  
  27. (select avg(fraction) * 10 as mediaPT FROM fhrw_question_attempt_steps mediaqas
  28. INNER JOIN fhrw_user mediau ON mediau.id=mediaqas.userid
  29. INNER JOIN fhrw_question_attempts mediaqa ON mediaqa.id=mediaqas.questionattemptid
  30. INNEr JOIN fhrw_question mediaq ON mediaq.id=mediaqa.questionid
  31. INNER JOIN fhrw_quiz_slots mediaqs ON mediaqs.questionid=mediaqa.questionid
  32. Inner Join fhrw_quiz mediaquiz ON mediaquiz.id=mediaqs.quizid
  33. inner Join fhrw_school mediaschool ON mediaschool.IdEscola=mediau.lastname
  34. where
  35. SUBSTRING(mediau.`department`,1,5) = $P{nivel}
  36. and SUBSTRING(mediau.`department`,6,1) = $P{turma}
  37. and mediaq.category = 7
  38. and mediaquiz.name=$P{simulado}
  39. and mediau.lastname=lastname
  40. and mediaqas.state!="todo"
  41. and mediaqas.state!="complete") as mediaGeralPT,
  42.  
  43. (select avg(fraction) * 10 as mediaPT FROM fhrw_question_attempt_steps mediaqas
  44. INNER JOIN fhrw_user mediau ON mediau.id=mediaqas.userid
  45. INNER JOIN fhrw_question_attempts mediaqa ON mediaqa.id=mediaqas.questionattemptid
  46. INNEr JOIN fhrw_question mediaq ON mediaq.id=mediaqa.questionid
  47. INNER JOIN fhrw_quiz_slots mediaqs ON mediaqs.questionid=mediaqa.questionid
  48. Inner Join fhrw_quiz mediaquiz ON mediaquiz.id=mediaqs.quizid
  49. inner Join fhrw_school mediaschool ON mediaschool.IdEscola=mediau.lastname
  50. where
  51. SUBSTRING(mediau.`department`,1,5) = $P{nivel}
  52. and SUBSTRING(mediau.`department`,6,1) = $P{turma}
  53. and mediaq.category = 8
  54. and mediaquiz.name=$P{simulado}
  55. and mediau.lastname=lastname
  56. and mediaqas.state!="todo"
  57. and mediaqas.state!="complete") as mediaGeralMT,
  58.  
  59. (select avg(fraction) * 10 as mediaPT FROM fhrw_question_attempt_steps mediaqas
  60. INNER JOIN fhrw_user mediau ON mediau.id=mediaqas.userid
  61. INNER JOIN fhrw_question_attempts mediaqa ON mediaqa.id=mediaqas.questionattemptid
  62. INNEr JOIN fhrw_question mediaq ON mediaq.id=mediaqa.questionid
  63. INNER JOIN fhrw_quiz_slots mediaqs ON mediaqs.questionid=mediaqa.questionid
  64. Inner Join fhrw_quiz mediaquiz ON mediaquiz.id=mediaqs.quizid
  65. inner Join fhrw_school mediaschool ON mediaschool.IdEscola=mediau.lastname
  66. where
  67. SUBSTRING(mediau.`department`,1,5) = $P{nivel}
  68. and SUBSTRING(mediau.`department`,6,1) = $P{turma}
  69. and mediaquiz.name=$P{simulado}
  70. and mediau.lastname=lastname
  71. and mediaqas.state!="todo"
  72. and mediaqas.state!="complete") as mediaGeral
  73.  
  74.  
  75.  
  76.  
  77.  
  78. FROM `fhrw_question_attempt_steps` qas
  79.  
  80. INNER JOIN fhrw_question_attempts qa ON qa.id=qas.`questionattemptid`
  81. INNER JOIN fhrw_quiz_slots qs ON qs.questionid=qa.questionid
  82. INNER JOIN fhrw_user u ON u.id = qas.userid
  83. INNER JOIN fhrw_question q ON q.id=qa.questionid
  84. Inner Join fhrw_quiz quiz ON quiz.id=qs.quizid
  85. inner Join fhrw_school school ON school.IdEscola=u.lastname
  86.  
  87. where
  88. quiz.name=$P{simulado}
  89. and u.lastname=lastname
  90. and SUBSTRING(u.`department`,1,5) = $P{nivel}
  91. and SUBSTRING(u.`department`,6,1) = $P{turma}
  92. and state!="todo"
  93. and state!="complete"
  94.  
  95. group by qa.questionid
  96. ORDER BY `Questao` ASC
Add Comment
Please, Sign In to add comment