Hi friends
following is my code for pivot table.
select * from
(select
sb.AdmissionNumber,
sa.RollNumber,
sc.Name,
sr.SubjectName,
sa.InternalMark,
sa.ExternalMark
from
schoolcampus.dbo.Mark_details sa
inner join
schoolcampus.dbo.StudentRollnumber_details sb on
sa.RollNumber = sb.RollNumber
inner join
StudentAdmission_details sc on
sc.AdmissionNumber = sb.AdmissionNumber
inner join
SubjectRegistration_details sr on
sr.SubjectCode = sa.SubjectCode
) p
PIVOT ( Max(InternalMark) for
SubjectName IN
( [English],
[Maths],
[Science],
[Social Science],
[Tamil]
)
) AS pvt
PIVOT ( Max(ExternalMark) for
SubjectName IN
( [English],
[Maths],
[Science],
[Social Science],
[Tamil]
)
) AS pvt1
and the error is t
Msg 207, Level 16, State 1, Line 1
Invalid column name 'SubjectName'.
Msg 265, Level 16, State 1, Line 1
The column name "English" specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument.
Msg 265, Level 16, State 1, Line 1
The column name "Maths" specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument.
Msg 265, Level 16, State 1, Line 1
The column name "Science" specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument.
Msg 265, Level 16, State 1, Line 1
The column name "Social Science" specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument.
Msg 265, Level 16, State 1, Line 1
The column name "Tamil" specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument.
Msg 8156, Level 16, State 1, Line 1
The column 'English' was specified multiple times for 'pvt1'.