Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends

following is my code for pivot table.

SQL
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'.
Posted
Updated 6-Oct-13 23:50pm
v2

1 solution

Quote:
You ask about problems and you already posted your problems please read your error messages they are clearly informing you about problems.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900