1
I have a query that returns the grades of students in certain tests. The amount of test may vary. I use the Pivot command to transform test names into columns and so organize test/note, as shown in the following image:
Where "SENEM_01", "02", "03" are test names. What I need is to average these values. Remembering that the test amount may vary.
My appointment is like this:
WITH notas_testes as(
SELECT
ft.inscricao,
ft.nota_num,
ft.idteste,
a.nome,
ft.unidade
from [Easy395].[dbo].[aluno] a
INNER JOIN [Easy395].[dbo].[faz_teste] ft
ON a.inscricao = ft.inscricao
)
select *
from notas_testes
PIVOT (SUM(nota_num) FOR idteste IN ([SENEM_01], [SENEM_02], [SENEM_03]))pvt