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