Set up school report

1

I'm trying to put together a SQL to display the results of a School Report Card. In the notes table I have the data as follows

Table Notes

MATERIA   | NOTA | BIMESTRE
PORTUGUES |  10  |   1
PORTUGUES |  8   |   2
PORTUGUES |  6   |   3
PORTUGUES |  5   |   4

To display this data I want it to look like this

MATERIA   |   1Bim   |   2Bim  |   3Bim   |    4Bim
PORTUGUES |    10    |     8   |     6    |     5

How can I do this?

    
asked by anonymous 15.06.2017 / 17:19

1 answer

1
Select max(case when bimestre = 1 then nota else null end) 1bim,
       Max(case when bimestre = 2 then nota else null end) 2bim,
       ...
From notas

It could, if necessary, group by student as well.

    
15.06.2017 / 20:07