use xjgl
go
--统计查询最高的身高,最矮的身高和全体学生的平均身高
select max(身高) as 最高身高,
min(身高) as 最低身高,
round (avg(身高),2) as 平均身高
from students
--查询各职称的人数
select 职称,count(*) as 人数
from teacher
group by 职称
--查询teacher 表中各职称的男女人数
select 职称,性别,count(*) as 总人数
from teacher
group by 职称,性别
--查询人数在3人以上的职称及其人数
select 职称,count(*) as 人数
from teacher group by 职称 having count(*)>=3
--查询工资多于1000的人数多于两人的教师的职称及其人数
select 职称,count(*) as 人数
from teacher
where 工资>1000
group by 职称 having count(*)>2
--利用union查询所有讲师和助教的姓名和职称
select 姓名,职称 from teacher
where 职称='讲师'
union
select 姓名,职称 from teacher
where 职称='助教'
--查询除助教以外的老师的姓名与职称
select 姓名,职称 from teacher
go
--统计查询最高的身高,最矮的身高和全体学生的平均身高
select max(身高) as 最高身高,
min(身高) as 最低身高,
round (avg(身高),2) as 平均身高
from students
--查询各职称的人数
select 职称,count(*) as 人数
from teacher
group by 职称
--查询teacher 表中各职称的男女人数
select 职称,性别,count(*) as 总人数
from teacher
group by 职称,性别
--查询人数在3人以上的职称及其人数
select 职称,count(*) as 人数
from teacher group by 职称 having count(*)>=3
--查询工资多于1000的人数多于两人的教师的职称及其人数
select 职称,count(*) as 人数
from teacher
where 工资>1000
group by 职称 having count(*)>2
--利用union查询所有讲师和助教的姓名和职称
select 姓名,职称 from teacher
where 职称='讲师'
union
select 姓名,职称 from teacher
where 职称='助教'
--查询除助教以外的老师的姓名与职称
select 姓名,职称 from teacher