行转列
表结构:

subject 科目
yw 语文
sx 数学
表数据:

转换SQL:
1 select name, 2 max(case subject when 'yw' then score else '' end) as yw , 3 max(case subject when 'sx' then score else '' end) as sx 4 from student_score group by name
转换结果:

转换过程:
根据学生姓名进行分组,并通过max取出相应科目的值

sql语句中有错误,你发现了吗?
 
                    
                     
                    
                 
                    
                 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号