I have one table in PostgreSQL which is like this (Img1)
From this table I am trying to achieve this (Img2)
I am trying to do this using CROSSTAB but in doing so I am not able to get Roll No Column. Below is the query that I am using.
SELECT * 
FROM CROSSTAB
('select student, subject, marks from dummy order by 1,2') 
AS FINAL
(
    Student TEXT, 
    Geography NUMERIC,
    History NUMERIC,
    Language NUMERIC,
    Maths NUMERIC,
    Music NUMERIC
);
How to achieve the expected output as I shown in (Img2)?


 
     
    