当前位置:Gxlcms > 数据库问题 > sql练习题

sql练习题

时间:2021-07-01 10:21:17 帮助过:6人阅读

技术图片

 

 

 分析:

要想对比不同行之间的数据大小,利用where不能直接对其进行对比,where只能对比不同列之间的数据,因此对同一个表join,将不同行对比的数据转换到列上。

技术图片

 

技术图片 

 

 select  stu.* , c1.score as ‘01课程分数‘ ,c2.score as ‘02课程分数‘  from SC c1 join SC c2 on  c1.SId = c2.SId  and c1.CId = ‘01‘

 and c2.CId = ‘02‘   join Student stu on  c1.SId = stu.SId  where  c1.score > c2.score

 

sql练习题

标签:image   sele   将不   技术   height   inf   数据转换   练习   sql练习   

人气教程排行