2022阿里、腾讯、字节都在问的SQL数据库笔试题及答案都给你整理好啦

在这里插入描述

2021到了最后一个月份,年后肯定有蛮多小伙伴需要跳槽换工作,但对于年限稍短的软件测试工程师,难免会需要进行笔试,而在笔试中,基本都会碰到一道关于数据库的大题,今天这篇文章呢,就收录了下最近学员反馈上来的一些数据库笔试真题,包含答案!

1、依据以下学生表、班级表,按要求写 SQL

图片

答案:

1、
select * from student a
left join class b on a.c_id = b.id
where score = (
select max(score) from student)

2、
select b.name,count(*),avg(score) as avgScore from student a,class b
where a.c_id = b.id
group by b.name
order by avgScore;

2、Table A 保存客户的基本信息;Table B 保存客户的资产负债信息。按要求写 SQL

图片

答案:

(1)select ID from A where name = ‘李四’;

(2)select NO,NAME,ID from A,B where A.NO = B.NO AND DEPOSIT >= 1000;

(3)select COUNTRY,count(*) FROM A GROUP BY COUNTRY;

(4)SELECT ‘80 后’ as 年龄段,sum(CREDIT) AS ‘信用卡余额’ FROM A,B WHERE A.NO = B.NO AND BIRTH >= 19800101 AND BIRTH < 19900101
UNION
SELECT ‘90 后’ as 年龄段,sum(CREDIT) AS ‘信用卡余额’ FROM A,B WHERE A.NO = B.NO AND BIRTH >= 19900101 AND BIRTH < 20000101;

3、数据库(编写示例 sql)

在这里插入图片描述

图片

答案:

1、select orderNo, if(status=1,‘新建’,‘处理中’) from OrderTrans;

2、select DATE_FORMAT(a.crttime,‘%m-%d-%Y’) ,username,count(*) from testCase a,User b where a.crtUser = b.UserId group by DATE_FORMAT(a.crttime,‘%m-%d-%Y’),b.username, having status = ‘成功’;

3、select count(*),sum(amount),DATE_FORMAT(crttime,‘%m-%d-%Y’) from OrderInfo group by
DATE_FORMAT(crttime,‘%m-%d-%Y’);

4、现有三张数据表如下:学生资料表:记录学生基本信息;课程表:记录课程基本信息;成绩表:记录每人各门课程成绩的信息,1 个学生对应多个成绩,1 个成绩只属于一个学生,一个课程

图片

答案:

1、Select * from students where jg = ‘湖北’ and birthday = ‘1992-6-1’ order by no asc;

2、Select avg(so.cj),min(so.cj),max(so.cj),sum(so.cj) from student st,course c,source so where st.no = so.no and c.kebh=so.kebh and st.name = ‘王华’ group by st.no;

3、Select st.no,st.name,st.bj,c.kebh,c.kcmc,so.cj from student st,course c,source so where st.no = so.no and c.kebh=so.kebh and st.name = ‘张三’ order by so.cj desc;

图片

图片

答案:

1、Select Consultant.SubsidiaryID, BaseOrder.* from Consultant, BaseOrder where Consultant.ConsultantID = BaseOrder.ConsultantID and Consultant.SubsidiaryID = 29 order by Orderid desc;

2、Select BaseOrder.ConsultantID,sum(OrderDetails.TotalPrice) from BaseOrder,OrderDetails where BaseOrder.Orderid=OrderDetails.Orderid and month(OrderDate) = 5 group by BaseOrder.ConsultantID;

3、Insert into Consultant (ConsultantID,ConstultantStatusID,SubsidiaryID,Name) values (200000,10,29,’Gary’);

4、Delete from Consultant where Name like ‘%Gary%’;

5、Update BaseOrder set OrderDate = sysdate() where ConsultantID in (select ConsultantID from BaseOrder where ConsultantID=100003 order by OrderDate desc limit 0,1);

最后可以在公众号:伤心的辣条 ! 免费领取,还有一份216页软件测试工程师面试宝典文档资料。以及相对应的视频学习教程免费分享!,其中资料包括了有基础知识、Linux必备、Shell、互联网程序原理、Mysql数据库、抓包工具专题、接口测试工具、测试进阶-Python编程、Web自动化测试、APP自动化测试、接口自动化测试、测试高级持续集成、测试架构开发测试框架、性能测试、安全测试等。

学习不要孤军奋战,最好是能抱团取暖,相互成就一起成长,群众效应的效果是非常强大的,大家一起学习,一起打卡,会更有学习动力,也更能坚持下去。你可以加入我们的测试技术交流扣扣群:914172719(里面有各种软件测试资源和技术讨论)

喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一键三连哦!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值