2019秋招多益游戏mysql题目-----列转行

2019秋招多益游戏mysql题目-----列转行

关于sql如下:

case when then 判断

select ‘年’,

   max(case when 季度=’1’ then 销量 else 0 end) as 第1季度,

   max(case when 季度=‘2’ then 销量 else 0 end) as 第2季度,

   max(case when 季度=’3’ then 销量 else 0 end ) as 第3季度,

   max(case when 季度=’4’ then 销量 else 0 end )as 第4季度

from sales

group by ‘年’;

同时请参考这篇博客: 

https://www.cnblogs.com/thomas12112406/p/5813394.html

另外附上2018用友秋招大数据开发的sql查询题目:

Student学生表(SNO学号, SNAME姓名, SEX性别,BIRTHDAY生日,DEP学院);

Course课程表(CNO课程编号, CNAME课程名字,CVAL学分);

Sc成绩表(SNO, CNO, SCORE成绩)

写一个sql查询挂科学分最多的学生和学院;

select a.SNAME,a.DEP ,count(*) as count from a.Sname,a.DEP from Student a,Course b,SC c where a.SNO=c.SNO and b.CNO=c.CNO and c.SCORE < 60 group by a.SNO order by count limint 1;

写sql 查询选修“数据结构”这门课的人数

select count(a.SNO) from Sc a, Course c where a.CNO = c.CNO and c.CNANE='数据结构';

写一个sql语句,查询“张宇”同学选修的课程和成绩:

select a.CNO, a.SCORE from SC a, Student b where a.SNO = b.SNO and b.SNAME = '张宇';