
狂刷MYSQL
PTA上的SQL练习练习题大全
三块不一样的石头
(๑•́ωก̀๑)打铁选手
展开
-
pta mysql训练题集(401-431)
10-401 查询课程“Dp010001”的最高分select max(grade) as max_gradefrom Gradewhere CourseID = 'Dp010001'10-402 查询课程“Dp010004”的学生学号和成绩,并按成绩降序排列,成绩相同按学号升序排列select StudentID,a.Gradefrom Grade as awhere CourseID = 'Dp010004' order by a.grade desc,studentID as原创 2022-05-21 12:59:41 · 20830 阅读 · 3 评论 -
pta mysql训练题集 (381-400)
10-381 查询选修了2门以上课程的学生学号和平均成绩。-- select sno as 学号, cast(avg(grade) as decimal(10,4)) as 平均分select sno as 学号, round(avg(grade),4) as 平均分from scoregroup by snohaving count(*) >= 210-382 查询商品相关信息(多表查询)select a.id as gid,a.name as gname,category原创 2022-05-21 12:50:37 · 11309 阅读 · 2 评论 -
pta mysql训练题集(361-380)
10-361 查询商品表中部分字段select id,category_id,name from sh_goods;10-362 简单条件查询数据select * from sh_goods where id = 1;10-363 修改商品表价格数据update sh_goods set price = 30 where id = 210-364 删除商品表数据delete from sh_goods where category_id != 3;10-365 获取每原创 2022-05-20 12:55:15 · 8307 阅读 · 0 评论 -
pta mysql训练题集(341-360)
10-341 把“李小鹏”同学的成绩全部删除delete from scwhere sno in (select sno from students where sname = '李小鹏');10-342 spj-查询没有使用天津供应商生产的红色零件的工程(MSSQL)select jno 工程项目号from j where jno not in ( select jno from spj,s,p where spj.sno = s.sno and sp..原创 2022-05-20 12:43:16 · 9793 阅读 · 0 评论 -
pta mysql训练题集(321-340)
10-321 查询“谭浩强”教师任课的课程号,选修其课程的学生的学号和成绩,结果中包括该老师没有被选修的课程select b.cno cno,c.sno sno,c.scorefrom teachers as aleft join teaching as b on b.tno=a.tnoleft join sc as c on b.cno=c.cno where a.tname='谭浩强'10-322 列出所有学生的选课情况(包括学号,姓名,课号,成绩),结果中包括没有选课的学生se原创 2022-05-20 11:31:29 · 11625 阅读 · 0 评论 -
pta mysql训练题集(301-320)
10-301 统计每门课程的选课人数和最高分select cno 课程号,count(*) 选课人数,max(score) 最高分from scgroup by cno10-302 查询选修了3门以上课程的学生学号select sno 学号,count(*) 选课门数from scgroup by snohaving count(*)>3;10-303 查询至少选修一门课程的学生学号select snofrom scgroup by snohaving cou原创 2022-05-20 11:15:29 · 10553 阅读 · 0 评论 -
pta mysql训练题集(281-300)
10-281 查询前3门课程的课号及课程名称select cno,cname from course limit 3;10-282 查询2050年所有学生的姓名及年龄,要求结果中列名显示中文select sname as 姓名,2050-year(bday) as 年龄from students10-283 查询至2050年所有年龄小于等于55岁的女生的学号和姓名select sno as 学号,sname as 姓名,ssex as 性别from studentswhere原创 2022-05-19 15:27:14 · 6508 阅读 · 0 评论 -
pta mysql训练题集(261-280)
10-261 查询平均成绩高于75分的学生(MSSQL)select sno as 学号,avg(grade) as 平均成绩from scgroup by snohaving avg(grade) > 7510-262 查询未登记成绩的学生select snofrom scwhere grade is null10-263 查询选修‘C语言’课程的学生select sname 姓名,grade 成绩from sc,stuwhere sc.sno=stu.sno原创 2022-05-19 15:13:57 · 4466 阅读 · 0 评论 -
pta mysql训练题集(241-260)
10-241 添加销售记录insert into recordervalues(null,'C008','G001',3,null),(null,'C008','G002',1,null);10-242 删除马齐的购物记录delete from recorderwhere cid=(select cid from customer where cname='马齐');10-243 修改杰克的购物记录。update recorder set quantity = 1wher原创 2022-05-19 12:22:01 · 8481 阅读 · 0 评论 -
pta mysql训练题集 (221-240)
10-221 检索所有女同学的基本信息。select *from studentwhere sex = '女'10-222 找出所有姓“李”的学生姓名、民族和联系电话。select sname,nation,phonefrom studentwhere sname like '李%';10-223 检索出所有成绩为空的学号,课号。select sno,cnofrom scorewhere grade is null10-224 检索出所有课程性质为“必修”的课程号、原创 2022-05-18 16:31:31 · 7802 阅读 · 0 评论 -
pta mysql 训练题集 (201-220)
10-201 在顾客表中查询青岛的顾客编号,公司名称和电话,结果按顾客编号升序排列select 顾客编号,公司名称,电话from 顾客where 城市 = '青岛';10-202 在顾客表中查询各个城市的顾客数目select 城市,count(*) as 顾客数from 顾客group by 城市;10-203 在订单表中查询运费的平均值select avg(运费) as 平均运费 from 订单;10-204 通过订单表和顾客表,查询订单编号,顾客编号,公司 名称和订原创 2022-05-18 14:01:45 · 5673 阅读 · 0 评论 -
pta mysql训练题集 ( 181-200 )
10-181 将员工表中编号为133的员工的性别修改为“男”update 员工set 性别 = '男' where 员工编号 = 133;10-182 在订单表中,查询运费在50元以下(不包括50元)的订单的全部信息select * from 订单 where 运费<50;10-183 在订单表中查询各位员工承办的订单数目select 员工编号,count(*) as 订单数from 订单group by 员工编号10-184 C1-1新增一个区域insert原创 2022-05-18 13:11:19 · 6001 阅读 · 0 评论 -
pta mysql 训练题集(161-180)
10-161 向借阅表中插入一条记录insert into 借阅(账号,条形码)values('D004','TP204.2');10-162 在读者表中查询全部读者信息,要求女性在前男性在后,同为女性读者的按账号升序排列select *from 读者order by 性别,账号;10-163 查询读者表中男女读者各自的人数select 性别,count(*) as 人数from 读者group by 性别;10-164 在读者表中查询余额最高的读者的全部信息原创 2022-05-18 10:05:45 · 8812 阅读 · 2 评论 -
pta mysql训练题集(141-160)
10-141 B1-8查询特定订单的详细信息select a.CustomerID,CompanyName,a.OrderID,ProductIDfrom orders as a, customers as b ,orderdetails as cwhere a.OrderID=c.OrderID and a.CustomerID=b.CustomerID and City='Madrid';10-142 查询图书表中售价介于50元到70元之间的图书的全部信息select * fr原创 2022-05-18 09:43:19 · 8144 阅读 · 0 评论 -
pta mysql训练题集 (121 - 140)
10-121 6-3 查询厂商"A"生产的PC的平均价格select avg(price) as avg_pricefrom pc,productwhere pc.model = product.model and product.maker = 'A';10-122 A4-6查找订单表中特定顾客编号的相关信息select CustomerID,sum(Freight) as sumFreightfrom orderswhere CustomerID like 'V%'grou..原创 2022-05-17 23:25:25 · 6319 阅读 · 0 评论 -
pta mysql训练题集 (101-120)
10-101 spj-查询比p6零件供应数量都高的零件select distinct pnofrom spjwhere pno not in ( select pno from spj where qty<=(select max(qty) from spj where pno='p6'));10-102 A3-1查询订单表中的平均运费select avg(Freight) as avgFreightfrom orders;10-103 A3-2查询国家为Me原创 2022-05-17 09:00:47 · 4889 阅读 · 0 评论 -
pta Mysql题目集 (81-100)
10-81 3-1-(c)查询在st1公司于2018年制作的电影中出演的影星select distinct starNamefrom StarsIn,Moviewhere StarsIn.movieTitle=Movie.title and StarsIn.movieYear=Movie.year and year=2018 and studioName='st1';10-82 A1-2根据所在国家查找订单信息select OrderID,CustomerIDfrom orders-原创 2022-05-16 20:40:21 · 4070 阅读 · 2 评论 -
pta mysql 训练题集 ( 61-80 )
10-61 2-1(b)查询影星S1的出生日期select birthdate from MovieStar where name='S1';10-62 A1-1查询联系人信息select CompanyName,ContactNamefrom customerswhere City='London'10-63 2-1-(c) 查询在1990年拍摄过电影的所有影星,或者拍摄过电影名中含有"3"的电影的所有影星select distinct starName from St原创 2022-05-16 14:30:49 · 5394 阅读 · 0 评论 -
10-77 spj-查询各工程项目使用所提供零件最多的供应商(详细解答)
本题目要求编写SQL语句,在SPJ数据库中,查询各工程项目使用所提供零件最多的供应商提示:请使用SELECT语句作答。如统计各工程项目的各供应商提供的零件数量和为:则每个工程项目的使用所提供最多零件数量的供应商分别为:表结构:请在这里写定义表结构的SQL语句。例如:CREATE TABLE `j` ( -- 工程项目表 `jno` char(3) NOT NULL,-- 工程项目号 `jname` varchar(10) DEFAULT NULL, `cit原创 2022-05-16 13:59:40 · 5231 阅读 · 0 评论 -
pta MYSQL 训练题集(41-60)
10-41 查询课程成绩最高二人select a.sno,sname,gradefrom( select sno,grade from sc where cno = 'C002' order by grade desc limit 2) as a,stuwhere a.sno = stu.sno10-42 查询选修张老师讲授所有课程的学生select snamefrom stuwhere sno in( select sno原创 2022-05-16 13:01:49 · 6207 阅读 · 0 评论 -
Mysql题目集(21-40)
10-21 查询学生表中大于19岁的女生select sno as 学号,sname as 姓名,sex as 性别,mno as 专业,(2020-year(birdate)) as 年龄,memo as 备注from stuwhere (2020-year(birdate)) > 19 and sex = 010-22 查询年龄18-20之间的学生信息select sno as 学号,sname as 姓名,sex as 性别,mno as 专业,(2020-year(bi原创 2022-05-15 18:07:22 · 4990 阅读 · 0 评论 -
PTA mysql训练题集(1-20题)
sql-sample查询xsda表中所有女生的记录查询xscj表中的学号,姓名,计算机三项信息,结果按计算机成绩的降序排列查询xscj表中的计算机成绩在80至90之间(包含80和90分)的同学的学号,姓名,计算机三项信息计算xscj表中计算机课程的最高分计算xscj表中计算机课程的最低分计算xscj表中英语课程的平均分统计xscj表中计算机课程成绩在90至100之间的人数查询xsda表中的学号、姓名、性别三项信息,结果按照女生优先的顺序显示统计xsda表中男女生的人数计算xsda表中男女原创 2022-05-14 20:22:37 · 11858 阅读 · 6 评论 -
10-1 sql-sample(超详细逐步解析)
本题目要求编写SQL语句,检索出每个班级中分数最低的同学id,姓名,分数,班级名称a111表结构:create table tb_student ( id int not null primary key, name varchar(32));create table tb_score ( stu_id int, score int);create table tb_class ( id int not null, name varchar(原创 2022-05-14 19:45:44 · 3320 阅读 · 1 评论