There is a table of performance. Fields:
ZachetkaId,SemesterId,DisciplinaId,Ocenka
I need to flip the table, so that the lines are zachetka (then I drag it through Fio's join), and the columns of the discipline. The fact is that such a code does this, but you need to know in advance which disciplines to work with, and I need a universal query, where I wouldn’t explicitly specify the discipline
SELECT * FROM ( SELECT zachetka,disciplina,ocenka FROM uspevaemostocenki WHERE disciplina IN('29','32','35','42') ) AS pr PIVOT ( max(ocenka) FOR disciplina IN([29],[32],[35],[42]) ) AS pvt
then replace with
SELECT * FROM ( SELECT zachetka,disciplina,ocenka FROM uspevaemostocenki WHERE disciplina IN(**select distinct disciplina from disciplini**) ) AS pr PIVOT ( max(ocenka) FOR disciplina IN([29],[32],[35],[42]) ) AS pvt
And I also need the same in the pivot request, but I can't insert the same request ...