【数据库】单表查询附答案

该博客详细展示了如何进行数据库单表查询,包括不同表的字段查询、表间关系分析,以及各种条件筛选,如按系部、专业、班级等信息进行查询,同时还涵盖了统计查询,如学生人数、班级人数、年龄分布等复杂查询操作。
摘要由CSDN通过智能技术生成

单表查询

--1  分别查询系部、专业、班级、学生、选课、课程、教师表中数据。

select * from Department

select * from Profession

select * from Class

select * from Student

select * from Course

select * from Teacher

2  根据要求查询结果分析这些表之间的关系。

--3  查询计算机工程系的信息。

select * from Department where DepartmentName='计算机工程系'

--4  查询计算机工程系的代码。

select DepartmentID from Department where DepartmentName='计算机工程系'

--5  查询电子工程系系主任的姓名。

select DepartmentHeader from Department where DepartmentName='电子工程'

--6  查询系部代码为01的专业信息。

select * from Profession where DepartmentID='01'

第二组

==

7  查询各系的专业个数。

select dept_num,count(*) as 专业个数 from Pro group by dept_num

8、查询专业名称含电字的专业信息

select * from Pro where pro_name like '%%'

9、查询06级班级信息。

select * from Class where class_num like '06%'

10 查询统计有几个软件技术班。

select count(*) as 软件班级个数from Class where class_name like '%软件技术%'

11 查询各年级的班级个数。

select left(class_num,2) as 年级, count(*) as 班级个数

from Class group by left(class_num

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值