• SQL 行转列


    表STUDENT_WishSchool 数据 :

    eduid  MiddleSchoolCode      WishCode  
    1      1000                  1  
    1      1001                  2  
    2      1000                  1  
    2      1001                  2  

     select EduId,    
     MAX(case when(WishCode='1') then MiddleSchoolCode end) as '第一志愿',   
     MAX(case when(WishCode='2') then MiddleSchoolCode end) as '第二志愿',   
     MAX(case when(WishCode='3') then MiddleSchoolCode end) as '第三志愿'    
     from STUDENT_WishSchool GROUP BY EduId   
    

    //结果  
    1   1000  10001  
    2   1000  10001 

  • 相关阅读:
    windows nginx
    stdClass 标准
    array_merge
    array_pop
    array_push
    array_unique
    GMT与UTC简介(转)
    curl-手册
    13.5. zipfile — Work with ZIP archives
    7. Input and Output
  • 原文地址:https://www.cnblogs.com/xiaoqi742709106/p/4275356.html
Copyright © 2020-2023  润新知