sql 面试基础 必会

1

#1
SELECT count(t_name) FROM teacher WHERE t_name like '李%';

#2
SELECT  DISTINCT sid,Sname,COUNT(expr) FROM student
--  3
SELECT student.*,score FROM sc LEFT JOIN student on sc.Sid=student.Sid 
WHERE cid=1 and score <(SELECT score FROM sc as p where p.sid=sc.sid and cid=2);


-- INSERT course VALUEs(7,'生物',7)
-- SELECT * FROM course
-- SELECT * FROM sc WHERE 
-- (SELECT *,tid FROM teacher WHERE Tname ='abc' ) not in
-- 
-- 
-- (SELECT cid FROM sc as p WHERE  p.sid=sc.Sid GROUP BY sid,cid )

-- 4SELECT * FROM student WHERE
 

SELECT * FROM student WHERE 
(SELECT cid FROM course WHERE tid=
(SELECT tid FROM teacher WHERE tname='张三' )) not in (
SELECT cid FROM sc WHERE sid=student.sid );

#5
SELECT * FROM course
SELECT * FROM student WHERE sid in
  ( SELECT if(COUNT( cid)<5,Sid,-1) FROM sc GROUP BY sid  );

# 6 
SELECT * FROM sc GROUP BY 

SELECT student.*,AVG(score) FROM student RIGHT JOIN sc on student.Sid=sc.Sid WHERE student.sid in
(SELECT if(sum( score <60)>=2,sid,-1) FROM sc GROUP BY sid )  GROUP BY sid;

7.ALTER
SELECT NULL 课程id,null 课程neme,null  最高分,null  最低分,null 平均分,null 及格,null 中等率,null 及格率 FROM sc




9
 SELECT *
FROM sc  WHERE ( SELECT sum(score>sc.score) FROM sc as p WHERE cid=sc.cid GROUP BY cid LIMIT 1
) <3 GROUP BY cid,sid  

 ORDER BY score DESC ;


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Captain_Data

打赏一下~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值