Guest User

Untitled

a guest
May 23rd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. begin tran
  2.  
  3. go
  4. CREATE PROCEDURE CalcularNota @matricula int
  5. AS
  6. SET NOCOUNT ON
  7.  
  8. insert into media_aluno (ERROS, ACERTOS, NOTA, MATRICULA, DIFICULDADE)
  9. select
  10. count(t2.resposta) AS ERROS,
  11. ((count(t2.resposta) - 20)*-1) as ACERTOS,
  12. (CAST(((count(t2.resposta) - 20)*-1) AS float)/2) AS MÉDIA,
  13. t2.MATRICULA,
  14. (select NOME_DIF FROM tic where PARAM_DIF = (select
  15. case when min(param_dif) = min(param_dif)
  16. then min(param_dif)
  17. else 15
  18. end as DIFICULDADE
  19. from tic
  20. where param_dif >= count(t2.resposta))) as DIFICULDADE
  21. from questoes t1
  22. inner join questoes_aluno t2 on (t1.questao = t2.questao)
  23. where t1.resposta <> t2.resposta
  24. and t2.MATRICULA = @matricula
  25. group by t2.nome, t2.MATRICULA
  26.  
  27.  
  28. GO
  29.  
  30. commit
  31.  
  32.  
  33. execute CalcularNota 3
Add Comment
Please, Sign In to add comment