CREATE TABLE Student(Std_no int, StdName TEXT, StdDegree TEXT, CourseName TEXT);
INSERT INTO Student(StdName, StdDegree, CourseName)
VALUES
('test1','att1','val1'),
('test1','att2','val2'),
('test1','att3','val3'),
('test1','att4','val4'),
('test2','att1','val5'),
('test2','att2','val6'),
('test2','att3','val7'),
('test2','att4','val8');
Select * from Student;
SELECT *
FROM crosstab(
'select StdName, StdDegree, CourseName
from Student
where StdDegree = 'att2'
or StdDegree = 'att3'
order by 1,2')
AS Student(row_name text, category_1 text, category_2 text, category_3 text);