Build school report

Asked

Viewed 307 times

1

I am trying to mount an SQL to display the results of a School Report Card. In the table of notes 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 that ?

  • https://forum.imasters.com.br/topic/551654-converter-linhas-em-colunas-pivot/ https://social.technet.microsoft.com/Forums/pt-BR/08b8e6b1-6b06-44bb-a5cd-f730e88c7ed6/coluna-em-linha?forum=transactsqlpt CASE , MAX and GROUP BY solves in SQL

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

Could , be the case , group by student also.

  • Motta thanks friend worked out

Browser other questions tagged

You are not signed in. Login or sign up in order to post.