sql面试题详解

本文深入剖析了SQL面试中常见的问题,包括查询语句优化、JOIN操作、子查询使用、事务处理以及数据库索引原理等方面,旨在帮助求职者更好地准备数据库相关的面试。
摘要由CSDN通过智能技术生成


 结果如下:

select a.sno,a.sname,avg(b.score) from student a left JOIN sc b on a.sno = b.sno GROUP BY a.sno having avg(score)>60
<pre name="code" class="sql">select a.sno,a.sname,count(b.cno),sum(b.score) from student a left join sc b on a.sno = b.sno group by sno

 
select a.sno,a.sname  from student a where a.sno not in (select a.sno from sc a inner join course b on a.cno = b.cno 
left join teaher c on b.tno = c.tno  where tname = '叶平')  


select a.sno,a.sname  from student a left join sc b on a.sno = b.sno group by a.sno having max(b.score)<60
或者
<span style="font-family: Arial, Helvetica, sans-serif;">select a.sno,a.sname  from student a left join sc b on a.sno = b.sno group by a.sno having count(b.score) = sum( case when b.score<60 then 1 else 0 end)</span>


select cno,max(score),min(score) from sc group by cno


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值