sir am getting records as below but i wants as i mention above
Subject |
Max_Marks |
UploadDate |
1 |
2 |
3 |
DRAWING |
20 |
9/22/2017 |
17 |
19 |
NULL |
ENGLISH |
20 |
9/22/2017 |
19 |
15 |
NULL |
EVS |
20 |
9/22/2017 |
18 |
18 |
NULL |
GEN. KNOWLEDGE |
20 |
9/22/2017 |
18 |
20 |
NULL |
HINDI |
20 |
9/22/2017 |
18 |
16 |
NULL |
MATHEMATICS |
20 |
9/22/2017 |
19 |
19 |
NULL |
MORAL EDUCATION |
20 |
9/22/2017 |
19 |
20 |
NULL |
my sql query is
DECLARE @Sttudent_Id INT
SET @Sttudent_Id = 10003
SELECT * FROM
(
SELECT [Subject],[Term],[Max_Marks],[Obt_Marks],[UploadDate] FROM Marks WHERE @Sttudent_Id = @Sttudent_Id
) as tbl
PIVOT(MAX(Obt_Marks) FOR [Term] IN ([1],[2],[3])) as PVT